EXPERTY DESIGNED 1Z0-809 PRACTICE TEST

Oracle 1Z0-809 Exam Questions
Total Questions: 469
Java SE 8 Programmer II
Updated On: Nov 24, 2025
Page : 1-47
Question 1

Given code of Test.java file: 

1. package com.udayan.ocp;

2.  

3. import java.util.ArrayDeque;

4. import java.util.Deque;

5.  

6. public class Test {

7.     public static void main(String[] args) {

8.         Deque deque = new ArrayDeque<>();

9.         deque.push(new Boolean("abc"));

10.         deque.push(new Boolean("tRuE"));

11.         deque.push(new Boolean("FALSE"));

12.         deque.push(true);

13.         System.out.println(deque.pop() + ":" + deque.peek() + ":" + deque.size());

14.     }

15. }

What will be the result of compiling and executing Test class?

Options :
Answer: A

Question 2

Below is the code of Test.java file:

1. package com.udayan.ocp;

2.  

3. class Outer {

4.     static class Inner {

5.         static void greetings(String s) {

6.             System.out.println(s);

7.         }

8.     }

9. }

10.  

11. public class Test {

12.     public static void main(String[] args) {

13.         /*INSERT*/

14.     }

15. }

Which of the following 2 options can replace /*INSERT*/ such that there on executing class Test, output is: HELLO!?

Options :
Answer: A,C

Question 3

F: is accessible for reading and below is the directory structure for F:

1. F:.

2. └───A

3.     └───B

4.         └───C

5.                 Book.java

'Book.java' file is available under 'C' directory.

Given code of Test.java file: 

1. package com.udayan.ocp;

2.  

3. import java.nio.file.Path;

4. import java.nio.file.Paths;

5.  

6. public class Test {

7.     public static void main(String[] args) {

8.         Path file = Paths.get("F:\\A\\B\\Book.java");

9.         System.out.println(file.toAbsolutePath());

10.     }

11. }

What will be the result of compiling and executing Test class?

Options :
Answer: A

Question 4

What will be the result of compiling and executing class M?

1. package com.udayan.ocp;

2.  

3. class M {

4.     private int num1 = 100;

5.     class N {

6.         private int num2 = 200;

7.     }

8.     

9.     public static void main(String[] args) {

10.         M outer = new M();

11.         M.N inner = outer.new N();

12.         System.out.println(outer.num1 + inner.num2);

13.     }

14. }

Options :
Answer: A

Question 5

Given:
class UserException extends Exception { }
class AgeOutOfLimitException extends UserException { }
and the code fragment:
class App {
 public void doRegister(String name, int age)
 throws UserException, AgeOutOfLimitException {
 if (name.length () < 6) {
 throw new UserException ();
 } else if (age >= 60) {
 throw new AgeOutOfLimitException ();
 } else {
 System.out.println(“User is registered.”);
 }
 }
 public static void main(String[ ] args) throws UserException {
 App t = new App ();
 t.doRegister(“Mathew”, 60);
 }
}
What is the result?

Options :
Answer: B

© Copyrights Oracledumps 2025. All Rights Reserved

We use cookies to ensure that we give you the best experience on our website (Oracledumps). If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the Oracledumps.