2 Language Fundamentals


2.1

(c)

52pickup is not a legal identifier. The first character of an identifier cannot be a digit.

2.2

(e)

In Java, the identifiers delete , thrown , exit , unsigned , and next are not keywords. Java has a goto keyword, but it is reserved and not currently used.

2.3

(b)

It is a completely valid comment. Comments do not nest. Everything from the start marker of a comment block ( /* ) until the first occurrence of the end marker of the comment block ( */) is ignored by the compiler.

2.4

(a) and (d)

String is a class, and "hello" and "t" denote String objects. Java only has the following primitive data types: boolean , byte , short , char , int , long , float , and double .

2.5

(a), (c), and (e)

Type (a) is a boolean data type, while types (c) and (e) are floating-point data types.

2.6

(c)

The bit representation of int is 32-bits wide and can hold values in the range “2 31 through 2 31 “1.

2.7

(a), (c), and (d)

The \u xxxx notation can be used anywhere in the source to represent unicode characters .

2.8

(c)

Local variable a is declared but not initialized . The first line of code declares the local variables a and b . The second line of code initializes the local variable b . Local variable a remains uninitialized .

2.9

(c)

The local variable of type float will remain uninitialized. Fields receive a default value unless explicitly initialized. Local variables remain uninitialized unless explicitly initialized. The type of the variable does not affect whether a variable is initialized or not.

2.10

(c)

The class will fail to compile since the package declaration can never occur after an import statement. The package and import statements, if present, must always precede any class definitions. If a file contains both import statements and a package statement, then the package statement must occur before the import statements.

2.11

true

Although nonsensical , an empty file is a valid source file. A source file can contain an optional package declaration, any number of import statements, and any number of class and interface definitions.

2.12

(d) and (f)

The main() method must be declared public , static , and void and takes a single array of String objects as argument. The order of the static and public keywords is irrelevant. Also, declaring the method final is irrelevant in this respect.

2.13

(a), (b), and (c)

Neither main , string , nor args are reserved keywords, but they are legal identifiers. In the declaration public static void main(String[] args) , the identifier main denotes the method that is the main entry point of a program. In all other contexts, the identifier main has no predefined meaning.



A Programmer[ap]s Guide to Java Certification
A Programmer[ap]s Guide to Java Certification
ISBN: 201596148
EAN: N/A
Year: 2003
Pages: 284

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net