1z0-808 | The Secret of Oracle 1z0-808 dumps


Q11. Given: 

public class TestLoop { 

public static void main(String[] args) { 

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

int key = 3; 

for (int pos = 0; pos < array.length; ++pos) { 

if (array[pos] == key) { 

break; 

System.out.print("Found " + key + "at " + pos); 

What is the result? 

A. Found 3 at 2 

B. Found 3 at 3 

C. Compilation fails 

D. An exception is thrown at runtime 

Answer:

Explanation: The following line does not compile: System.out.print("Found " + key + "at " + pos); 

The variable pos is undefined at this line, as its scope is only valid in the for loop. Any variables created inside of a loop are LOCAL TO THE LOOP. 

Q12. Which two are benefits of polymorphism? 

A. Faster code at runtime 

B. More efficient code at runtime 

C. More dynamic code at runtime 

D. More flexible and reusable code 

E. Code that is protected from extension by other classes 

Answer: C,D 

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

Q14. Given the code fragment: 

Which option represents the state of the num array after successful completion of the outer loop? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Q15. Given: 

What is the result? 

A. 120 

B. 120D 

C. A NumberFormatException will be thrown. 

D. Compilation fails due to error at line 5. 

E. Compilation tails due to error at line 8. 

Answer:

Explanation: 

At line 5, we have created a wrapper object of double by passing 120D, which is convertible to a Double, so there won't be any exception there. But if you check carefully, you can see the variable number is declared inside try block, so the scope of the variable number is limited to that block, so trying to access it outside causes a compile time error. httpsy/docs.oracle.com/javase/tutorial/iava/nutsandbolts/variables.html 

Q16. Given the code fragment: 

What is the result? 

A. Sum is 600 

B. Compilation fails at line n1. 

C. Compilation fails at line n2. 

D. A ClassCastException is thrown at line n1. 

E. A ClassCastException is thrown at line n2. 

Answer:

Q17. Given: 

What is the result? 

A. true:true 

B. true:false 

C. false:true 

D. false:false 

Answer:

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

Q19. Given: 

What is the result? 

A. hEllOjAvA! 

B. Hello java! 

C. Out of limits hEllOjAvA! 

D. Out of limits 

Answer:

Q20. Given the code fragment: 

What is the result? 

A. Reading Card Checking Card 

B. Compilation fails only at line n1. 

C. Compilation fails only at line n2. 

D. Compilation fails only at line n3. 

E. Compilation fails at both line n2 and line n3. 

Answer: