1z0-808 Exam - Java SE 8 Programmer I

certleader.com

Q1. Given: 

public class Test1 { 

static void doubling (Integer ref, int pv) { 

ref =20; 

pv = 20; 

public static void main(String[] args) { 

Integer iObj = new Integer(10); 

int iVar = 10; 

doubling(iObj++, iVar++); 

System.out.println(iObj+ ", "+iVar); 

What is the result? 

A. 11, 11 

B. 10, 10 

C. 21, 11 

D. 20, 20 

E. 11, 12 

Answer:

Explanation: The code doubling(iObj++, iVar++); increases both variables from to 10 to 

11. 

Q2. Given: 

And given the commands: 

javac Test.Java 

Java Test Hello 

What is the result? 

A. Success 

B. Failure 

C. Compilation fails. 

D. An exception is thrown at runtime 

Answer:

Q3. Given the code fragment: 

And given the requirements: 

. If the value of the qty variable is greater than or equal to 90, discount = 0.5 

. If the value of the qty variable is between 80 and 90, discount = 0.2 

Which two code fragments can be independently placed at line n1 to meet the requirements? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

E. Option E 

Answer: A,C 

Q4. Given: 

And the commands: 

Javac Test.java 

Java Test 12345 

What is the result? 

A. Number us : 12345 

B. A NullPointerException is thrown at runtime 

C. A NumberFormatException is thrown at runtime 

D. AnArrayIndexOutOfBoundException is thrown at runtime. 

Answer:

Q5. Which two statements correctly describe checked exception? 

A. These are exceptional conditions that a well-written application should anticipate and recover from. 

B. These are exceptional conditions that are external to the application, and that the application usually cannot anticipate or recover from. 

C. These are exceptional conditions that are internal to the application, and that the application usually cannot anticipate or recover from. 

D. Every class that is a subclass of RuntimeException and Error is categorized as checked exception. 

E. Every class that is a subclass of Exception, excluding RuntimeException and its subclasses, is categorized as checked exception. 

Answer: B,D 

Explanation: Checked exceptions: 

* (B) represent invalid conditions in areas outside the immediate control of the program (invalid user input, database problems, network outages, absent files) 

* are subclasses of Exception It's somewhat confusing, but note as well that RuntimeException (unchecked) is itself a subclass of Exception (checked). 

* a method is obliged to establish a policy for all checked exceptions thrown by its implementation (either pass the checked exception further up the stack, or handle it somehow) 

Reference: Checked versus unchecked exceptions 

Q6. Given: 

What is the result? 

A. True false 

B. True null 

C. Compilation fails 

D. A NullPointerException is thrown at runtime 

Answer:

Q7. Given: 

public class TestLoop1 { 

public static void main(String[] args) { 

int a = 0, z=10; 

while (a < z) { 

a++; 

--z; 

} System.out.print(a + " : " + z); } } 

What is the result? 

A. 5 : 5 

B. 6 : 4 

C. 6 : 5 

D. 5 : 4 

Answer:

Q8. public class ForTest { 

public static void main(String[] args) { 

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

for ( foo ) { 

Which three are valid replacements for foo so that the program will compiled and run? 

A. int i: array 

B. int i = 0; i < 1; i++ 

C. ;; 

D. ; i < 1; i++ 

E. ; i < 1; 

Answer: A,B,C 

Q9. Given: 

What is the result? 

A. Good Day! Good Luck! 

B. Good Day! Good Day! 

C. Good Luck! Good Day! 

D. Good Luck! Good Luck! 

E. Compilation fails 

Answer:

Q10. Given the code fragment: 

What is the result? 

A. May 04, 2014T00:00:00.000 

B. 2014-05-04T00:00: 00. 000 

C. 5/4/14T00:00:00.000 

D. An exception is thrown at runtime. 

Answer:

Explanation: 

java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: HourOfDay