EXPERTY DESIGNED 1Z0-809 PRACTICE TEST

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

Given code of Test.java file: 

1. package com.udayan.ocp;

2.  

3. public class Test {

4.     private static String msg = "Hello";

5.  

6.     private static String changeMsg(String m) {

7.         msg = m;

8.         return null;

9.     }

10.  

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

12.         if(args.length == 0) {

13.             assert false : changeMsg("Bye");

14.         }

15.         System.out.println(msg);

16.     }

17. }

What will be the result of executing Test class with below command? 

java -ea com.udayan.ocp.Test

Options :
Answer: C

Question 2

Given code of Test.java file: 

1. package com.udayan.ocp;

2.  

3. import java.util.Arrays;

4. import java.util.List;

5. import java.util.ListIterator;

6.  

7. public class Test {

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

9.         List list = Arrays.asList("T", "S", "R", "I", "F");

10.         ListIterator iter = list.listIterator(2);

11.         while(iter.hasNext()) {

12.             System.out.print(iter.next());

13.         }

14.     }

15. }

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

Options :
Answer: B

Question 3

Given the code fragments:
class MyThread implements Runnable {
 private static AtomicInteger count = new AtomicInteger (0);
 public void run () {
 int x = count.incrementAndGet();
 System.out.print (x+” “);
 }
}
and
Thread thread1 = new Thread(new MyThread());
Thread thread2 = new Thread(new MyThread());
Thread thread3 = new Thread(new MyThread());
Thread [] ta = {thread1, thread2, thread3};
for (int x= 0; x < 3; x++) {
 ta[x].start();
}
Which statement is true?

Options :
Answer: A

Question 4

Consider the code of Greet.java file:

1. package com.udayan.ocp;

2.  

3. public final class Greet {

4.     private String msg;

5.     public Greet(String msg) {

6.         this.msg = msg;

7.     }

8.  

9.     public String getMsg() {

10.         return msg;

11.     }

12.  

13.     public void setMsg(String msg) {

14.         this.msg = msg;

15.     }

16. }

Is Greet class an immutable class?

Options :
Answer: B

Question 5

Given:
public class Counter {
 public static void main (String[ ] args) {
 int a = 10;
 int b = -1;
 assert (b >=1) : “Invalid Denominator”;
 int с = a / b;
 System.out.println (c);
 }
}
What is the result of running the code with the –da option?

Options :
Answer: A

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