1Z0-803 | Realistic Java 1Z0-803 practice test


Q91. Given the code fragment: 

What is the result? 

A. 10 8 6 4 2 0 

B. 10 8 6 4 2 

C. An Arithmetic Exception is thrown at runtime 

D. The program goes into an infinite loop outputting: 10 8 6 4 2 0. . . 

E. Compilation fails 

Answer:

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

Q93. View the exhibit. 

Given the code fragment: 

Which change enables the code to print the following? 

James age: 20 

Williams age: 32 

A. Replacing line 5 with public static void main (String [] args) throws MissingInfoException, 

AgeOutofRangeException { 

B. Replacing line 5 with public static void main (String [] args) throws.Exception { 

C. Enclosing line 6 and line 7 within a try block and adding: 

catch(Exception e1) { //code goes here} 

catch (missingInfoException e2) { //code goes here} 

catch (AgeOutofRangeException e3) {//code goes here} 

D. Enclosing line 6 and line 7 within a try block and adding: 

catch (missingInfoException e2) { //code goes here} 

catch (AgeOutofRangeException e3) {//code goes here} 

Answer:

Q94. Which code fragment, when inserted at line 9, enables the code to print true? 

A. String str2 = str1; 

B. String str2 = new string (str1); 

C. String str2 = sb1.toString(); 

D. String str2 = “Duke”; 

Answer:

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

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

Q97. 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