To
Sun Certified Programmer for Java 2 platform (Exam 310-025)
Document version control
Date
Author
Version
Comment
12/09/2001
Ashraf Fouad
1.0 beta
Creation
Correction:
(2.1): missing j variable, operators were not correct
(2.3): s1 = “YES” instead of “yes”
27/01/2002
Ashraf Fouad
1.0 final
Released
Note To Holders:
If you receive an electronic copy of this document and print it out, please write your name on the equivalent of the cover page, for document control purposes.
If you receive a hard copy of this document, please write your name on the front cover, for document control purposes.
Contributors:
My site Visitors
Chapter 1:
Language fundamentals
1.1) Which of the following lines are valid declarations? [1] [3]
(a) char a = ‘\u0061’;
(b) char \u0061 = ‘a’;
(c) ch\u0061r a = ‘a’;
(d) char a = (char) 65;
1.2) Is an empty file a valid source file? [1]
(a) True.
(b) False.
1.3) Which of these are valid declaration of the main() method? [1]
(a) static void main(String args[]) {/* … */}
(b) public static int main(String args[]) {/* … */}
(c) public static void main(String args) {/* … */}
(d) final static public void main(String[] arguments) {/* … */}
(e) public int main(String args[], int argc) {/* … */}
(f) public void main(String args[]) {/* … */}
1.4) Which one of the following are not valid character contants? [8]
Select any two.
(a) char c = '\u00001' ;
(b) char c = '\101';
(c) char c = 65;
(d) char c = '\1001' ;
Top of Form
Bottom of Form
Answers:
1.1) (a), (b), (c), (d)
All are valid declarations. The \uxxxx notation can be used anywhere in the source to represent Unicode characters, and also casted integer to a char primitive type.
1.2) (a)
Although nonsensical, an empty file ia a valid source file. A source file can contain an optional package declaration, any number of import statements and any number of