1z0-808 Premium Bundle

1z0-808 Premium Bundle

Java SE 8 Programmer I Certification Exam

4.5 
(27120 ratings)
0 QuestionsPractice Tests
0 PDFPrint version
November 26, 2024Last update

Oracle 1z0-808 Free Practice Questions

Q1. Give: 

What is the result? 

A. 1525 

B. 13 

C. Compilation fails 

D. An exception is thrown at runtime 

E. The program fails to execute due to runtime error 

Answer:

Q2. Given: 

abstract class A1 { 

public abstract void m1(); 

public void m2() { System.out.println("Green"); } 

abstract class A2 extends A1 { 

public abstract void m3(); 

public void m1() { System.out.println("Cyan"); } 

public void m2() { System.out.println("Blue"); } 

public class A3 extends A2 { 

public void m1() { System.out.println("Yellow"); } 

public void m2() { System.out.println("Pink"); } 

public void m3() { System.out.println("Red"); } 

public static void main(String[] args) { 

A2 tp = new A3(); 

tp.m1(); 

tp.m2(); 

tp.m3(); 

What is the result? 

A. Yellow Pink Red 

B. Cyan Blue Red 

C. Cyan Green Red 

D. Compilation Fails 

Answer:

Q3. Given: 

Which code fragment, when inserted at line 7, enables the code print true? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

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

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

Q6. Given the code fragment: 

What could expression1 and expression2 be, respectively, in order to produce output –8, 16? 

A. + +a, - -b 

B. + +a, b- -

C. A+ +, - - b 

D. A + +, b - -

Answer:

Q7. Given: 

What is the result? 

A. 11, 21, 31, 11, 21, 31 

B. 11, 21, 31, 12, 22, 32 

C. 12, 22, 32, 12, 22, 32 

D. 10, 20, 30, 10, 20, 30 

Answer:

Q8. Given: 

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:

Q9. Given: 

What is the result? 

A. simaple A 

B. Capital A 

C. simaple A default Capital A 

D. simaple A default 

E. Compilation fails. 

Answer:

Explanation: 

Here we have to use two ternary operators combined. SO first we can use to check first 

condition which is x > 10, as follows; 

x>10?">": (when condition false) Now we have to use another to check if x<10 as follows; 

x<10?V:"=" We can combine these two by putting last ternary statement in the false 

position of first ternary statement as follows; 

x>10?">":x<10?'<':"=" 

https;//docs.oraclexom/javase/tutorial/java/nutsandbolts/if.html 

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

Q11. Given the code fragment: 

What is the result if the integer aVar is 9? 

A. 10 Hello World! 

B. Hello Universe! 

C. Hello World! 

D. Compilation fails. 

Answer:

Q12. Given the code fragment: 

System.out.println(2 + 4 * 9 - 3); //Line 21 

System.out.println((2 + 4) * 9 - 3); // Line 22 

System.out.println(2 + (4 * 9) - 3); // Line 23 

System.out.println(2 + 4 * (9 - 3)); // Line 24 

System.out.println((2 + 4 * 9) - 3); // Line 25 

Which line of codes prints the highest number? 

A. Line 21 

B. Line 22 

C. Line 23 

D. Line 24 

E. Line 25 

Answer:

Explanation: The following is printed: 35 51 

35 

26 

35 

Q13. Given the following class: 

And given the following main method, located in another class: 

Which three lines, when inserted independently at line n1, cause the program to print a o balance? 

A. this.amount = 0; 

B. amount = 0; 

C. acct (0) ; 

D. acct.amount = 0; 

E. acct. getAmount () = 0; 

F. acct.changeAmount(0); 

G. acct.changeAmount(-acct.amount); 

H. acct.changeAmount(-acct.getAmount()); 

Answer: D,G,H 

Q14. Given the code fragment: 

Which code fragment, when inserted at // insert code here, enables the code to compile and and print a b c? 

A. List update (String[] strs) 

B. Static ArrayListupdate(String [] strs) 

C. Static List update (String [] strs) 

D. Static void update (String[] strs) 

E. ArrayList static update(String [] strs) 

Answer:

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

START 1z0-808 EXAM