Question ID: UK8296394Consider below code of Test.java file:package com.examtest.ocp; public class Test { public static void main(String[] args) { var sb = new StringBuilder(); System.out.println(sb.append("").append("").append("").length()); }}What is the result?
Question ID: UK8297735Given code of Test.java file:package com.examtest.ocp; public class Test { enum TrafficLight { private String message; GREEN("go"), AMBER("slow"), RED("stop"); TrafficLight(String message) { this.message = message; } public String getMessage() { return message; } } public static void main(String[] args) { System.out.println(TrafficLight.AMBER.getMessage().toUpperCase()); }} What is the result?
Question ID: UK8298565Consider below code of Test.java file:package com.examtest.ocp; public class Test { public static void main(String[] args) { String str = "*"; /*INSERT*/ System.out.println(str); }}Which of the following options, if used to replace /*INSERT*/, will compile successfully and on execution will print ***** on to the console?Choose 2 options.
Question ID: UK8296388Consider below code of Test.java file:package com.examtest.ocp; public class Test { public static void main(String[] args) { final var str = "+"; System.out.println(str.repeat(2) == "++"); }}What is the result?
Question ID: UK8298570Consider below code of Test.java file:package com.examtest.ocp; public class Test extends String { @Override public String toString() { return "TEST"; } public static void main(String[] args) { Test obj = new Test(); System.out.println(obj); }}What is the result?
© Copyrights FreePDFQuestions 2026. All Rights Reserved
We use cookies to ensure that we give you the best experience on our website (FreePDFQuestions). If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the FreePDFQuestions.