Oracle 1Z0-809

Page:    1 / 94   
Total 469 questions | Updated On: Apr 25, 2024
Question 1

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?


Answer: A
Question 2

Given code of Test.java file: 

1. package com.udayan.ocp;

2.  

3. import java.util.Arrays;

4. import java.util.Comparator;

5. import java.util.List;

6.  

7. public class Test {

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

9.         List list = Arrays.asList(10, 20, 8);

10.         

11.         System.out.println(list.stream().max(Comparator.comparing(a -> a)).get()); //Line 1

12.  

13.         System.out.println(list.stream().max(Integer::compareTo).get()); //Line 2

14.  

15.         System.out.println(list.stream().max(Integer::max).get()); //Line 3

16.     }

17. }

Which of the following statement is true?


Answer: C
Question 3

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


Answer: A
Question 4

Given:

3
and the code fragment:
4
What is the result?


Answer: B
Question 5

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


Answer: C
Page:    1 / 94   
Total 469 questions | Updated On: Apr 25, 2024

Quickly grab our 1Z0-809 product now and kickstart your exam preparation today!

Name: Java SE 8 Programmer II
Exam Code: 1Z0-809
Certification: Oracle Java
Vendor: Oracle
Total Questions: 469
Last Updated: Apr 25, 2024