1Z0-803 Exam - Java SE 7 Programmer I

certleader.com

Q1. public class MyFor { 

public static void main(String[] args) { 

for (int ii = 0; ii < 4; ii++) { 

System.out.println("ii = "+ ii); 

ii = ii +1; 

What is the result? 

A. ii = 0 

ii = 2 

B. ii = 0 

ii = 1 

ii = 2 

ii = 3 

C. ii = 

D. Compilation fails. 

Answer:

Q2. Which three are valid types for switch?

A. int

B. float

C. double

D. integer

E. String

F. Float

Answer: ADE

Q3. Given: 

public class SampleClass { 

public static void main(String[] args) { 

AnotherSampleClass asc = new AnotherSampleClass(); SampleClass sc = new 

SampleClass(); 

sc = asc; 

System.out.println("sc: " + sc.getClass()); 

System.out.println("asc: " + asc.getClass()); 

}} 

class AnotherSampleClass extends SampleClass { 

What is the result? 

A. sc: class Object asc: class AnotherSampleClass 

B. sc: class SampleClass asc: class AnotherSampleClass 

C. sc: class AnotherSampleClass asc: class SampleClass 

D. sc: class AnotherSampleClass asc: class AnotherSampleClass 

Answer:

Q4. Given: 

Which three lines will compile and output “right on!”? 

A. Line 5 

B. Line 6 

C. Line 7 

D. Line 8 

E. Line 9 

F. Line 10 

Answer: CDF 

Q5. Given the code fragment: 

A. Super Sub Sub 

B. Contract Contract Super 

C. Compilation fails at line n1 

D. Compilation fails at line n2 

Answer:

Q6. Given the code format: 

Which code fragment must be inserted at line 6 to enable the code to compile? 

A. DBConfiguration f; return f; 

B. Return DBConfiguration; 

C. Return new DBConfiguration; 

D. Retutn 0; 

Answer:

Q7. Given: 

What is the result? 

A. 0 

B. 0 1 2 

C. 0 1 2 0 1 2 0 1 2 

D. Compilation fails 

Answer:

Q8. Given: 

What is the result? 

A. Shining Sun 

Shining Sun 

Shining Sun 

B. Shining Sun 

Twinkling Star 

Shining Sun 

C. Compilation fails 

D. A ClassCastException is thrown at runtime 

Answer:

Q9. Given: 

What is the result? 

A. 1 1 1 

B. 1 2 3 

C. 2 3 4 

D. Compilation fails 

E. The loop executes infinite times 

Answer:

Q10. Given the code fragment: 

Which statement is true? 

A. After line 8, three objects are eligible for garbage collection 

B. After line 8, two objects are eligible for garbage collection 

C. After line 8, one object is eligible for garbage collection 

D. After line 8, none of the objects are eligible for garbage collection 

Answer: