1z0-808 | A Review Of Certified 1z0-808 exam question


Q41. Given: 

What is the result? 

A. 97 98 99 100 null null null 

B. 91 98 99 100 101 102 103 

C. Compilation rails. 

D. A NullPointerException is thrown at runtime. 

E. An ArraylndexOutOfBoundsException is thrown at runtime. 

Answer:

Q42. Given: 

class MarksOutOfBoundsException extends IndexOutOfBoundsException { } 

public class GradingProcess { 

void verify(int marks) throws IndexOutOfBoundsException { 

if (marks > 100) { 

throw new MarksOutOfBoundsException(); 

if (marks > 50) { 

System.out.print("Pass"); 

} else { 

System.out.print("Fail"); 

public static void main(String[] args) { 

int marks = Integer.parseInt(args[2]); 

try { 

new GradingProcess().verify(marks)); 

} catch(Exception e) { 

System.out.print(e.getClass()); } } } 

And the command line invocation: 

Java grading process 89 50 104 

What is the result? 

A. Pass 

B. Fail 

C. Class MarketOutOfBoundsException 

D. Class IndexOutOfBoundsException 

E. Class Exception 

Answer:

Explanation: The value 104 will cause a MarketOutOfBoundsException 

Q43. Given the code fragment: 

public static void main(String[] args) { 

int iArray[] = {65, 68, 69}; 

iArray[2] = iArray[0]; 

iArray[0] = iArray[1]; 

iArray[1] = iArray[2]; 

for (int element : iArray) { 

System.out.print(element + " "); 

A. 68, 65, 69 

B. 68, 65, 65 

C. 65, 68, 65 

D. 65, 68, 69 

E. Compilation fails 

Answer:

Q44. Given: 

What is the result? 

A. 1 

B. 1 

C. 2 

D. Compilation fails 

E. The loop executes infinite times 

Answer:

Q45. Given the code fragment: 

String[] cartoons = {"tom","jerry","micky","tom"}; 

int counter =0; 

if ("tom".equals(cartoons[0])) { 

counter++; 

} else if ("tom".equals(cartoons[1])) { 

counter++; 

} else if ("tom".equals(cartoons[2])) { 

counter++; 

} else if ("tom".equals(cartoons[3])) { 

counter++; 

System.out.print(counter); 

What is the result? 

A. 1 

B. 2 

C. 4 

D. 0 

Answer:

Explanation: Counter++ will be executed only once because of the else if constructs. 

Q46. Which of the following will print current time? 

A. System.out.print(new LocalTime()-now0); 

B. System.out.print(new LocalTime()); 

C. System.ouLprint(LocalTime.now()); 

D. System.ouLprint(LocalTime.today()); 

E. None of the above. 

Answer:

Explanation: 

The LocalTime is an interface, so we can't use new keyword with them. So options A and C are incorrect. To get current time we can call now method on LocalTime interface. So option C is correct. Option D is incorrect as there is no method called today as in LocalTime interface 

https://docs.oracle.com/javase/tutorial/datetime/iso/datetime.html 

Q47. Given the code fragment: 

What is the result? 

A. Values are : [EE, ME] 

B. Values are : [EE, EE, ME] 

C. Values are : [EE, ME, EE] 

D. Values are : [SE, EE, ME, EE] 

E. Values are : [EE, ME, SE, EE] 

Answer:

Q48. Given the code fragment: 

What is the result? 

A. Element 0 Element 1 

B. Null element 0 Null element 1 

C. Null Null 

D. A NullPointerException is thrown at runtime. 

Answer:

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

Answer:

Q50. Given: 

public class MainMethod { 

void main() { 

System.out.println("one"); 

static void main(String args) { 

System.out.println("two"); 

public static void main(String[] args) { 

System.out.println("three"); 

void mina(Object[] args) { 

System.out.println("four"); 

What is printed out when the program is excuted? 

A. one 

B. two 

C. three 

D. four 

Answer: