Oracle Certified Professional Java Se 11 Developer Exam Questions & Answers

Practice 110 free Oracle Certified Professional Java Se 11 Developer exam questions with answers and community-discussed explanations. Each question has its own page where you can reveal the correct answer and debate it in the comments.

All 110 questions

  1. Q1 Question ID: UKOCP26808Given code: package com.udayankhattry.ocp; import java.text.SimpleDateFormat;import java.util.Date; public class Test { public static void main(String [] args) { var date = new…
  2. Q2 Question ID: UKOCP21636Consider below code of Test.java file: package com.udayankhattry.ocp; public class Test { public static void main(String[] args) { var x =…
  3. Q3 Question ID: UKOCP39360Given code: package com.udayankhattry.ocp; class Outer { private String name = "NOW OR NEVER"; //Insert inner class definition here} public class Test…
  4. Q4 Question ID: UKOCP63850Given code: package com.udayankhattry.ocp; import java.util.*; public class Test { public static void main(String[] args) { var list = new ArrayList<String>(List.of("T", "O",…
  5. Q5 Question ID: UKOCP38050Consider below code of Test.java file: package com.udayankhattry.ocp; public class Test { public static void main(String[] args) { boolean b1 =…
  6. Q6 Question ID: UKOCP80724Given below the directory/file structure on Windows platform: C:+---src| \---messages| | module-info.java| || \---com| \---udayankhattry| \---ocp| Main.java| Test.java|+---bin| \---messages| |…
  7. Q7 Question ID: UKOCP48535You as a developer, have task to modularize an application, which contains 3 jars: x.jar, y.jar and z.jar. x.jar depends…
  8. Q8 Question ID: UKOCP70946Given code: package com.udayankhattry.ocp; import java.security.*;import java.util.*;import java.util.stream.Collectors; class Attacker { private final List<Integer> attackCoordinates = new ArrayList<>(List.of(100, 276, 190));  public final…
  9. Q9 Question ID: UKOCP29193Consider below codes of 3 java files://M.javapackage com.udayankhattry.ocp; public class M { public void printName() { System.out.println("M"); }}//N.javapackage com.udayankhattry.ocp; public class N…
  10. Q10 Question ID: UKOCP29082Given code of Fast annotation:package com.udayankhattry.ocp; import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME)@Target(ElementType.TYPE)public @interface Fast { /*INSERT*/}And code of RoadRunner.java file: package com.udayankhattry.ocp; @Fast("15MPH")public class RoadRunner {}RoadRunner.java…
  11. Q11 Question ID: UKOCP28176What are the security best practices related to native methods?
  12. Q12 Question ID: UKOCP26465Given code of Test.java file: package com.udayankhattry.ocp; import java.util.Arrays;import java.util.Comparator;import java.util.List; class Student implements Comparator<Student> { private String name; private String exam; …
  13. Q13 Question ID: UKOCP14012Given code: package com.udayankhattry.ocp; interface Writer { void print(Object obj);} public class Test { public static void main(String[] args) { Writer obj…
  14. Q14 Question ID: UKOCP23777Following resource bundle files are defined for the project: ResourceBundle_CA.propertiesResourceBundle_hi.propertiesResourceBundle_IN.propertiesResourceBundle.propertiesAll the resource bundle files have same keys.The default locale of…
  15. Q15 Question ID: UKOCP83800Given structure of EMPLOYEE table: EMPLOYEE (ID integer, FIRSTNAME varchar(100), LASTNAME varchar(100), SALARY real, PRIMARY KEY (ID))EMPLOYEE table contains below…
  16. Q16 Question ID: UKOCP86428Given code: package com.udayankhattry.ocp; import java.io.*;import java.util.List;import java.util.Optional; public class Test { public static void main(String[] args) throws IOException, ClassNotFoundException { var…
  17. Q17 Question ID: UKOCP69133Given code: package com.udayankhattry.ocp; import java.util.Optional;import java.util.stream.Stream; public class Test { public static void main(String[] args) { Stream<Number> stream = Stream.of(); Optional<Number>…
  18. Q18 Question ID: UKOCP20791Consider below code of Test.java file: package com.udayankhattry.ocp;  public class Test { public static void main(String[] args) { StringBuilder sb…
  19. Q19 Question ID: UKOCP19357Given code of Test.java file: package com.udayankhattry.ocp; import java.io.FileNotFoundException;import java.io.IOException; abstract class Super { public abstract void m1() throws IOException;} class Sub extends…
  20. Q20 Question ID: UKOCP19766What will be the result of compiling and executing Test class?//Test.javapackage com.udayankhattry.ocp; class Student { String name; int marks; Student(String name,…
  21. Q21 Question ID: UKOCP45182Given code: package com.udayankhattry.ocp; import java.util.function.BiFunction;import java.util.function.BiPredicate; public class Test { public static void main(String[] args) { BiFunction<String, String, String> func =…
  22. Q22 Question ID: UKOCP77559Given below the directory/file structure on Windows platform: C:├───src│ └───<MODULE_DIRECTORY_NAME>│ │ module-info.java│ ││ └───com│ └───messages│ Test.java│└───outBelow is the code of…
  23. Q23 Question ID: UKOCP32218Given structure of EMPLOYEE table: EMPLOYEE (ID integer, FIRSTNAME varchar(100), LASTNAME varchar(100), SALARY real, PRIMARY KEY (ID))EMPLOYEE table contains below…
  24. Q24 Question ID: UKOCP16290Consider below code of Test.java file: package com.udayankhattry.ocp; public class Test { public static void main(String[] args) { StringBuilder sb =…
  25. Q25 Question ID: UKOCP13183Given code:package com.udayankhattry.ocp; import java.util.function.UnaryOperator; public class Test { public static void main(String[] args) { UnaryOperator<String> opr = s -> s.toString().toUpperCase(); //Line…
  26. Q26 Question ID: UKOCP22518Given code of Test.java file: package com.udayankhattry.ocp; import java.sql.SQLException; public class Test { private static void checkData() throws SQLException { try {…
  27. Q27 Question ID: UKOCP32368Consider below codes of 4 java files: //I1.javapackage com.udayankhattry.ocp; public interface I1 { int i = 10;}//I2.javapackage com.udayankhattry.ocp; public interface I2 {…
  28. Q28 Question ID: UKOCP55895What will be the result of compiling and executing Test class?package com.udayankhattry.ocp; public class Test { enum JobStatus { SUCCESS, FAIL;…
  29. Q29 Question ID: UKOCP87305Given code: import java.io.*; public class Test { public static void main(String[] args) throws IOException { var console = System.console(); var…
  30. Q30 Question ID: UKOCP42088What will be the result of compiling and executing TestPoint class?package com.udayankhattry.ocp; import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;import java.util.List; class Point { private int…
  31. Q31 Question ID: UKOCP20750Below is the code of Test.java file:package com.udayankhattry.ocp; interface Flyable { void fly();} public class Test { public static void main(String[] args)…
  32. Q32 Question ID: UKOCP14052Consider below code of the Test.java file: package com.udayankhattry.ocp; public class Test { public static void main(String[] args) { int ctr…
  33. Q33 Question ID: UKOCP80739Below options are given to guard sensitive data during serialization: 1. Declare sensitive fields transient2. Define the serialPersistentFields array field…
  34. Q34 Question ID: UKOCP83821Given code of Test.java file: package com.udayankhattry.ocp; import java.util.List;import java.util.Map; public class Test { public static void main(String[] args) { var map1…
  35. Q35 Question ID: UKOCP37185Given code: package com.udayankhattry.ocp; class Outer { public void print(int x) { class Inner { public void getX() { System.out.println(++x); }…
  36. Q36 Question ID: UKOCP42049Given code: package com.udayankhattry.ocp; import java.text.*;import java.time.format.DateTimeFormatter;import java.util.Locale; public class Test { public static void main(String[] args) { var dateFormatter = DateTimeFormatter.ofPattern("dd-MM-uuuu");…
  37. Q37 Question ID: UKOCP86082Given structure of EMPLOYEE table: EMPLOYEE (ID integer, FIRSTNAME varchar(100), LASTNAME varchar(100), SALARY real, PRIMARY KEY (ID))Given code of Test.java…
  38. Q38 Question ID: UKOCP27708Given code of Test.java file:package com.udayankhattry.ocp; class Printer<String> { private String t; Printer(String t){ this.t = t; } public String toString()…
  39. Q39 Question ID: UKOCP33145Given code: package com.udayankhattry.ocp; import java.util.List;import java.util.Map;import java.util.Set; public class Test { public static void main(String[] args) { var list = List.of("A",…
  40. Q40 Question ID: UKOCP16131F: is accessible for reading/writing and below is the directory structure for F:F:.└───Parent │ a.txt │ b.txt │ └───Child c.txt…
  41. Q41 Question ID: UKOCP21659Consider codes of 3 java files://Class1.javapackage com.udayankhattry.ocp; import java.io.FileNotFoundException; public class Class1 { public void read() throws FileNotFoundException {}}//Class2.javapublic class Class2 {…
  42. Q42 Question ID: UKOCP42910Given code: package com.udayankhattry.ocp; import java.util.Comparator;import java.util.stream.Stream; public class Test { public static void main(String[] args) { Stream<String> stream = Stream.of("d", "a",…
  43. Q43 Question ID: UKOCP63462Consider below code of Test.java file: package com.udayankhattry.ocp; public class Test { public static void main(String[] args) { int elements =…
  44. Q44 Question ID: UKOCP35329Given code of Test.java file: package com.udayankhattry.ocp; import java.util.*; enum TrafficLight { RED, YELLOW, GREEN} public class Test { public static void main(String[]…
  45. Q45 Question ID: UKOCP61265Following statement in a Java program compiles successfully:student.report(course);What can you say for sure?
  46. Q46 Question ID: UKOCP84358Given code: package com.udayankhattry.ocp; interface I1 { void m1();} public class Test { public static void main(String[] args) { I1 i1 =…
  47. Q47 Question ID: UKOCP27389Given code: package com.udayankhattry.ocp; class Logger { public void log() { System.out.println("GO FOR IT"); }} public class Test { public static void…
  48. Q48 Question ID: UKOCP87313Which of the below classes help you to define recursive task? Choose 2 options.
  49. Q49 Question ID: UKOCP22069Given code: package com.udayankhattry.ocp; import java.util.Arrays;import java.util.List; public class Test { public static void main(String[] args) { StringBuilder [] arr = {new…
  50. Q50 Question ID: UKOCP51352F: is accessible for reading/writing and below is the directory structure for F:F:.└───A └───B Book.javaBook.java is a text file.   …
  51. Q51 Question ID: UKOCP80735Consider below code: package com.udayankhattry.ocp; import java.time.LocalDate; public class Test { public static void main(String[] args) { LocalDate d1 = null; //Value…
  52. Q52 Question ID: UKOCP66115Below are the possible definitions of Printable interface: 1. public abstract interface Printable {}2. public interface Printable { protected void…
  53. Q53 Question ID: UKOCP16668Given code: package com.udayankhattry.ocp; import java.util.*; public class Test { public static void main(String[] args) { Collection<Integer> list = List.of(100, 100, 100);…
  54. Q54 Question ID: UKOCP26854Given code of Test.java file: package com.udayankhattry.ocp; import java.util.ArrayDeque;import java.util.Deque; public class Test { public static void main(String[] args) { Deque<Character> chars…
  55. Q55 Question ID: UKOCP38399Given code: package com.udayankhattry.ocp; import java.nio.file.Paths; public class Test { public static void main(String[] args) { var file1 = Paths.get("F:\\A\\B\\C"); var file2…
  56. Q56 Question ID: UKOCP53245Consider below codes of 3 java files: //Profitable1.javapackage com.udayankhattry.ocp; public interface Profitable1 { default double profit() { return 12.5; }}//Profitable2.javapackage com.udayankhattry.ocp; public…
  57. Q57 Question ID: UKOCP61623Given code of Test.java file: package com.udayankhattry.ocp; import java.io.IOException;import java.sql.SQLException; class MyResource implements AutoCloseable { @Override public void close() throws IOException{ throw…
  58. Q58 Question ID: UKOCP22028Given code of Test.java file: package com.udayankhattry.ocp; class Resource implements AutoCloseable { public void close() { System.out.println("CLOSE"); }} public class Test {…
  59. Q59 Question ID: UKOCP83498Consider below code:package com.udayankhattry.ocp; interface Operator<T> { T operate(T t);} public class Test { public static void main(String[] args) { Operator<String> opr…
  60. Q60 Question ID: UKOCP36738Consider below codes of 4 java files://A.javapackage com.udayankhattry.ocp; public class A { public void print() { System.out.println("A"); }}//B.javapackage com.udayankhattry.ocp; public class B…
  61. Q61 Question ID: UKOCP80759Given code: package com.udayankhattry.ocp; import java.time.*;import java.time.format.*; public class Test { public static void main(String [] args) { var date = LocalDateTime.of(2025,…
  62. Q62 Question ID: UKOCP14017Built-in functional interfaces are part of which java package?
  63. Q63 Question ID: UKOCP87887Given code:package com.udayankhattry.ocp; class A { public void someMethod(final String name) { /*INSERT*/ { void print() { System.out.println("Hello " + name);…
  64. Q64 Question ID: UKOCP80791Which of the 4 interfaces must be implemented by a JDBC driver?
  65. Q65 Question ID: UKOCP74539Given code: package com.udayankhattry.ocp; interface Operation { long operate(Integer x, Integer y);} public class Test { public static void main(String[] args) {…
  66. Q66 Question ID: UKOCP20799Consider below code of Test.java file: package com.udayankhattry.ocp; public class Test { public static void main(String[] args) { StringBuilder sb =…
  67. Q67 Question ID: UKOCP88283What will be the result of compiling and executing Test class?package com.udayankhattry.ocp; import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;import java.util.List; class Point { private int…
  68. Q68 Question ID: UKOCP37160Given code: package com.udayankhattry.ocp; public class Test { public static void main(String[] args) { /*INSERT*/ switch(var) { case 10: System.out.println("TEN"); break;…
  69. Q69 Question ID: UKOCP68695What will be the result of compiling and executing Test class?package com.udayankhattry.ocp; import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;import java.util.List; class Point { private int…
  70. Q70 Question ID: UKOCP79426Consider below code of Test.java file: package com.udayankhattry.ocp; class Shape { int side = 0; //Line n1  int getSide() { //Line…
  71. Q71 Question ID: UKOCP30884Given code: package com.udayankhattry.ocp; import java.io.*; class Counter implements Serializable { private static int count = 0; public Counter() { count++; } …
  72. Q72 Question ID: UKOCP20637Given code: package com.udayankhattry.ocp; import java.util.Comparator;import java.util.List; public class Test { public static void main(String[] args) { var list = List.of(10, 20,…
  73. Q73 Question ID: UKOCP54104Given Code:import java.io.*; class ReadTheFile { static void print() { //Line n1 throw new IOException(); //Line n2 }} public class Test {…
  74. Q74 Question ID: UKOCP42179Given code of LogHelper.java file: package com.udayankhattry.ocp; abstract class Helper { int num = 100; String operation = null; protected abstract…
  75. Q75 Question ID: UKOCP34034Consider below code of Test.java file:package com.udayankhattry.ocp; import java.util.Arrays; public class Test { public static void main(String[] args) { char [] arr1…
  76. Q76 Question ID: UKOCP64791Consider below code of Test.java file: package com.udayankhattry.ocp; public class Test { public static void main(String[] args) { var res =…
  77. Q77 Question ID: UKOCP62170Consider below code of Test.java file: package com.udayankhattry.ocp;  public class Test { public static void main(String[] args) { String s1…
  78. Q78 Question ID: UKOCP78832Given code: package com.udayankhattry.ocp; import java.io.*; public class Test { public static void main(String[] args) throws IOException { var file = new…
  79. Q79 Question ID: UKOCP61251Given code: package com.udayankhattry.ocp; class P { private int var = 100; class Q { String var = "Java"; void print()…
  80. Q80 Question ID: UKOCP14416Consider below code of Test.java file: package com.udayankhattry.ocp; public class Test { public static void main(String[] args) { int [] arr…
  81. Q81 Question ID: UKOCP80738Given code: package com.udayankhattry.ocp; import java.security.AccessController;import java.security.PrivilegedAction; public class PropertyReader { public static String get(final String key) { PrivilegedAction<String> pa = ()…
  82. Q82 Question ID: UKOCP47710Given structure of LOG table: LOG (ID integer, MESSAGE varchar(1000), PRIMARY KEY (ID))LOG table contains below records: 1001 Login Successful1002…
  83. Q83 Question ID: UKOCP54125Given code of Test.java file: package com.udayankhattry.ocp; public class Test { static int a = 10000; static { a = -a--;…
  84. Q84 Question ID: UKOCP52747Given code: package com.udayankhattry.ocp; interface Dancer { default void dance() { System.out.println("DANCER"); }} interface TapDancer extends Dancer { void dance();} public class Test…
  85. Q85 Question ID: UKOCP78958Consider below code of Test.java file: package com.udayankhattry.ocp;  public class Test { public static void main(String[] args) { StringBuilder sb…
  86. Q86 Question ID: UKOCP29169Given code of Test.java file: package com.udayankhattry.ocp; import java.io.FileNotFoundException; public class Test { public static void main(String[] args) { try { findSecretFile();…
  87. Q87 Question ID: UKOCP42123Given code of Test.java file: package com.udayankhattry.ocp; import java.io.IOException; class Super { Super() throws RuntimeException { System.out.print("CARPE "); }} class Sub extends Super…
  88. Q88 Question ID: UKOCP27260Given code: package com.udayankhattry.ocp; import java.io.*;import java.nio.file.Files;import java.nio.file.Paths; public class Test { public static void main(String[] args) throws IOException { /*INSERT*/ }}F:…
  89. Q89 Question ID: UKOCP35818Consider below codes of 3 java files: //Buyable.javapackage com.udayankhattry.ocp; public interface Buyable { int salePercentage = 85;  public static String salePercentage()…
  90. Q90 Question ID: UKOCP51494Consider below code of Test.java file: package com.udayankhattry.ocp; public class Test { public static void main(String [] args) { var a…
  91. Q91 Question ID: UKOCP27770Given code: package com.udayankhattry.ocp; import java.util.stream.Stream; public class Test { public static void main(String[] args) { Stream<Double> stream = Stream.generate(() -> Double.valueOf("1.0"))…
  92. Q92 Question ID: UKOCP21057A named module can access classes present in the _____________ but not in the _____________.
  93. Q93 Question ID: UKOCP45559Given code: package com.udayankhattry.ocp; import java.time.*;import java.time.format.DateTimeFormatter; public class Test { public static void main(String [] args) { var date = LocalDate.of(2023,…
  94. Q94 Question ID: UKOCP75425Given code: package com.udayankhattry.ocp; abstract class Greetings { abstract void greet();} public class Test { public static void main(String[] args) { var…
  95. Q95 Question ID: UKOCP66404Given code: package com.udayankhattry.ocp; import java.util.Arrays;import java.util.stream.Stream; public class Test { public static void main(String[] args) { Stream<Integer> stream = Arrays.asList(1,2,3,4,5).stream(); System.out.println(stream.sum());…
  96. Q96 Question ID: UKOCP56671Given structure of EMPLOYEE table: EMPLOYEE (ID integer, FIRSTNAME varchar(100), LASTNAME varchar(100), SALARY real, PRIMARY KEY (ID))EMPLOYEE table contains below…
  97. Q97 Question ID: UKOCP75077Consider below code of TestSquare.java file: package com.udayankhattry.ocp; class Square { int length; Square sq; Square(int length) { this.length = length;…
  98. Q98 Question ID: UKOCP31328Given code: package com.udayankhattry.ocp; public class Event { private String name; private int age;  public Event(String name, int age) { this.name…
  99. Q99 Question ID: UKOCP23716A module is a set of ____________.
  100. Q100 Question ID: UKOCP44683Given structure of MESSAGES table:MESSAGES (msg1 varchar(100), msg2 varchar(100))MESSAGES table contains below records: 'Happy New Year!', 'Happy Holidays!'Given code of…
  101. Q101 Question ID: UKOCP68250Consider below code of Test.java file: package com.udayankhattry.ocp; import java.util.ArrayList;import java.util.List; public class Test { public static void main(String[] args) { List<String>…
  102. Q102 Question ID: UKOCP38454Given code: package com.udayankhattry.ocp; /*INSERT*/ public class Test { public static void main(String[] args) { MyInterface mi = () -> ""; }}Which…
  103. Q103 Question ID: UKOCP81279Given code: package com.udayankhattry.ocp; import java.util.*;import java.util.function.*; public class Test { public static void main(String[] args) { Set<Integer> set = new HashSet<>();…
  104. Q104 Question ID: UKOCP89501Given code: package com.udayankhattry.ocp; import java.util.stream.Stream; public class Test { public static void main(String[] args) { var str1 = Stream.iterate(1, k ->…
  105. Q105 Question ID: UKOCP42141Given code of Test.java file: package com.udayankhattry.ocp; public class Test { static String str = "KEEP IT "; //Line n1 public…
  106. Q106 Question ID: UKOCP50130What will be the output of compiling and executing the Test class?package com.udayankhattry.ocp; public class Test { public static void main(String[]…
  107. Q107 Question ID: UKOCP26430Given code: package com.udayankhattry.ocp; import java.util.stream.Stream; public class Test { public static void main(String[] args) { Stream.of() .map(s -> s.reverse()) .forEach(System.out::println); }}What…
  108. Q108 Question ID: UKOCP10968What will be the result of compiling and executing Test class?package com.udayankhattry.ocp; public class Test { public static void main(String []…
  109. Q109 Question ID: UKOCP47829Consider below code of Wall.java file: package com.udayankhattry.ocp; public class Wall { public static void main(String args[]) { double area =…
  110. Q110 Question ID: UKOCP26028What will be the result of compiling and executing Test class?package com.udayankhattry.ocp; public class Test { public static void main(String[] args)…

More Oracle certifications

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need