Q51. Given: 

What is the result? 

A. null 

B. compilation fails 

C. Java.lang.NullPointerException 

D. 0 

Answer:


Q52. What is the result? 

A. 100 210 

B. Compilation fails due to an error in line n1 

C. Compilation fails due to an error at line n2 

D. Compilation fails due to an error at line n3 

Answer:


Q53. Given: 

What three modifications, made independently, made to class greet, enable the code to compile and run? 

A. line 6 replaced with handy.dandy.keystroke stroke = new KeyStroke ( ); 

B. line 6 replaced with handy.*.KeyStroke = new KeyStroke ( ); 

C. line 6 replaced with handy.dandy.KeyStroke Stroke = new handy.dandy.KeyStroke(); 

D. import handy.*; added before line 1 

E. import handy.dandy.*; added after line 1 

F. import handy.dandy,KeyStroke; added after line 1 

G. import handy.dandy.KeyStroke.typeException(); added before line 1 

Answer: CEF 


Q54. A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the result? 

A. Compilation fails. 

B. The third argument is given the value null. 

C. The third argument is given the value void. 

D. The third argument is given the value zero. 

E. The third argument is given the appropriate false value for its declared type. 

F. An exception occurs when the method attempts to access the third argument. 

Answer:


Q55. Given the fragments: 

Which line causes a compilation error? 

A. Line n1 

B. Line n2 

C. Line n3 

D. Line n4 

Answer:


Q56. Given: 

Given the for loop construct: 

Which constructor initializes the variable x3? 

A. Only the default constructor of class X 

B. Only the no-argument constructor of class Y 

C. Only the no-argument constructor of class Z 

D. Only the default constructor of object class 

Answer:


Q57. Given a code fragment: 

 

A. They match They real match 

B. They really match 

C. They match 

D. Nothing is printed to the screen 

Answer:


Q58. What is the result? 

A. Initialized 

Started 

B. Initialized 

Started 

Initialized 

C. Compilation fails 

D. An exception is thrown at runtime 

Answer:


Q59. Which two will compile, and can be run successfully using the command: 

Java fred1 hello walls 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer: CD 


Q60. An unchecked exception occurs in a method dosomething() Should other code be added in the dosomething() method for it to compile and execute? 

A. The Exception must be caught 

B. The Exception must be declared to be thrown. 

C. The Exception must be caught or declared to be thrown. 

D. No other code needs to be added. 

Answer: