Become Oracle Certified with updated 1Z0-809 exam questions and correct answers
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
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?
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!?
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
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. class Person {
8. private String firstName;
9. private String lastName;
10.
11. public Person(String firstName, String lastName) {
12. this.firstName = firstName;
13. this.lastName = lastName;
14. }
15.
16. public String getFirstName() {
17. return firstName;
18. }
19.
20. public String getLastName() {
21. return lastName;
22. }
23.
24. public String toString() {
25. return "{" + firstName + ", " + lastName + "}";
26. }
27. }
28.
29. public class Test {
30. public static void main(String[] args) {
31. List
32. new Person("Tom", "Riddle"),
33. new Person("Tom", "Hanks"),
34. new Person("Yusuf", "Pathan"));
35. list.stream().sorted(Comparator.comparing(Person::getFirstName).reversed()
36. .thenComparing(Person::getLastName)).forEach(System.out::println);
37. }
38. }
What will be the result of compiling and executing Test class?
Given code of Test.java file:
1. package com.udayan.ocp;
2.
3. interface Printer1 {
4. default void print() {
5. System.out.println("Printer1");
6. }
7. }
8.
9. class Printer2 {
10. public void print() {
11. System.out.println("Printer2");
12. }
13. }
14.
15. class Printer extends Printer2 implements Printer1 {
16.
17. }
18.
19. public class Test {
20. public static void main(String[] args) {
21. Printer printer = new Printer();
22. printer.print();
23. }
24. }
What will be the result of compiling and executing Test class?
© Copyrights DumpsCertify 2025. All Rights Reserved
We use cookies to ensure your best experience. So we hope you are happy to receive all cookies on the DumpsCertify.