Q111. Given: 

What is the result? 

A. box 

B. nbo 

C. bo 

D. nb 

E. An exception is thrown at runtime 

Answer:


Q112. Given the code fragment: 

What is the result? 

A. 20 

B. 25 

C. 29 

D. Compilation fails 

E. AnArrayIndexOutOfBoundsException is thrown at runtime 

Answer:


Q113. 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:


Q114. Given the code fragment: 

Which code fragment, when inserted at line 3, enables the code to print 10:20? 

A. int[] array n= new int[2]; 

B. int[] array; array = int[2]; 

C. int array = new int[2]; 

D. int array [2] ; 

Answer:


Q115. Given: 

What is the result? 

A. true true 

B. true false 

C. false true 

D. false false 

E. Compilation fails 

Answer:


Q116. Which two are Java Exception classes? 

A. SercurityException 

B. DuplicatePathException 

C. IllegalArgumentException 

D. TooManyArgumentsException 

Answer: A,C 


Q117. Given: 

What is the result? 

A. Compilation fails 

B. The code compiles, but does not execute. 

C. Paildrome 

D. Wow 

E. Mom 

Answer:


Q118. Consider following method 

Which statement is true? 

A. This method is invalid. 

B. This method can be used only in an interface. 

C. This method can return anything. 

D. This method can be used only in an interface or an abstract class. 

E. None of above. 

Answer:

Explanation: 

Given method is declared as default method so we can use it only inside an interface. 

Hence option B is correct and option D is incorrect. 

Option A is incorrect as it is valid method. Option C is incorrect as return type is void, which 

means we can't return anything. 


Q119. Given the code fragment: 

public class ForTest { 

public static void main(String[] args) { 

int[] array = {1, 2, 3}; 

for ( foo ) { 

Which three code fragments, when replaced individually for foo, enables the program to compile? 

A. int i : array 

B. int i = 0; i < 1; 

C. ; ; 

D. ; i < 1; i++ 

E. i = 0; i<1; 

Answer: A,B,C 


Q120. Given: 

Given: 

public class SuperTest { 

public static void main(String[] args) { 

statement1 

statement2 

statement3 

class Shape { 

public Shape() { 

System.out.println("Shape: constructor"); 

public void foo() { 

System.out.println("Shape: foo"); 

class Square extends Shape { 

public Square() { 

super(); 

public Square(String label) { 

System.out.println("Square: constructor"); 

public void foo() { 

super.foo(); 

public void foo(String label) { 

System.out.println("Square: foo"); 

What should statement1, statement2, and statement3, be respectively, in order to produce the result? 

Shape: constructor 

Square: foo 

Shape: foo 

A. Square square = new Square ("bar"); 

square.foo ("bar"); 

square.foo(); 

B. Square square = new Square ("bar"); 

square.foo ("bar"); 

square.foo ("bar"); 

C. Square square = new Square (); 

square.foo (); 

square.foo(bar); 

D. Square square = new Square (); 

square.foo (); 

square.foo("bar"); 

E. Square square = new Square (); 

square.foo (); 

square.foo (); 

F. Square square = new Square(); 

square.foo("bar"); 

square.foo(); 

Answer: