Q71. Given the code fragment: 

What is the result? 

A. Execution terminates in the first catch statement, and caught a RuntimeException is printed to the console. 

B. Execution terminates In the second catch statement, and caught an Exception is printed to the console. 

C. A runtime error is thrown in the thread "main". 

D. Execution completes normally, and Ready to us. is printed to the console. 

E. The code fails to compile because a throws keyword is required. 


Q72. Given: 

And given the code fragment: 

What is the result? 

A. 4W 100 Auto 4W 150 Manual 

B. Null 0 Auto 4W 150 Manual 

C. Compilation fails only at line n1 

D. Compilation fails only at line n2 

E. Compilation fails at both line n1 and line n2 



On line n1 implicit call to parameterized constructor is missing and n2 this() must be the first line. 

Q73. Given: 

What is the result? 

A. 200.0 : 100.0 

B. 400.0 : 200.0 

C. 400.0 : 100.0 

D. Compilation fails. 


Q74. Which two are benefits of polymorphism? 

A. Faster code at runtime 

B. More efficient code at runtime 

C. More dynamic code at runtime 

D. More flexible and reusable code 

E. Code that is protected from extension by other classes 

Answer: C,D 

Q75. Given the following code: 

What is the output? 

A. 4 

B. 3 

C. 4 

D. 5 

E. 4 

F. 4 



Q76. Given the code fragment: 

What is the result if the integer aVar is 9? 

A. 10 Hello World! 

B. Hello Universe! 

C. Hello World! 

D. Compilation fails. 


Q77. Given the content of three files: 

Which statement is true? Which statement is true? 

A. Only the A.Java file compiles successfully. 

B. Only the B.java file compiles successfully. 

C. Only the C.java file compiles successfully. 

D. The A.Java and B.java files compile successfully. 

E. The B.java and C.java files compile successfully. 

F. The A.Java and C.java files compile successfully. 


Explanation: In class B.Java doStuff() has access modifier with variable name which is not allowed. C.Java class name is different than file name. Only private classes can have different names than file names 

Q78. Given the code fragment: 

List colors = new ArrayList(); 








What is the result? 

A. [green, red, yellow, cyan] 

B. [green, blue, yellow, cyan] 

C. [green, red, cyan, yellow] 

D. Am IndexOutOfBoundsException is thrown at runtime 


Explanation: First the list [green, red, blue, yellow] is build. 

The blue element is removed: 

[green, red, yellow] 

Finally the element cyan is added at then end of the list (index 3). 

[green, red, yellow, cyan] 

Q79. Which two actions will improve the encapsulation of a class? 

A. Changing the access modifier of a field from public to private 

B. Removing the public modifier from a class declaration 

C. Changing the return type of a method to void 

D. Returning a copy of the contents of an array or ArrayList instead of a direct reference 

Answer: A,D 

Reference: http://www.tutorialspoint.com/java/java_access_modifiers.htm 

Q80. Given: 

public class SampleClass { 

public static void main(String[] args) { 

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


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