Question ID: UK8294624Given code:package com.examtest.ocp; class Outer { private String msg = "A"; public void print() { final String msg = "B"; class Inner { public void print() { System.out.println(this.msg); } } Inner obj = new Inner(); obj.print(); }} public class Test { public static void main(String[] args) { new Outer().print(); }}What is the result?
Question ID: UK8294645Given code of Test.java file:package com.examtest.ocp; import java.io.IOException;import java.sql.SQLException; class MyResource implements AutoCloseable { @Override public void close() throws IOException{ throw new IOException("IOException"); } public void execute() throws SQLException { throw new SQLException("SQLException"); }} public class Test { public static void main(String[] args) { try(MyResource resource = new MyResource()) { resource.execute(); } catch(Exception e) { System.out.println(e.getMessage()); } }}What is the result?
Question ID: UK8291549Given code of Test.java file:package com.examtest.ocp; public class Test { private static void m(int i) { System.out.print(1); } private static void m(int i1, int i2) { System.out.print(2); } private static void m(char... args) { System.out.print(3); } public static void main(String... args) { m('A'); m('A', 'B'); m('A', 'B', 'C'); m('A', 'B', 'C', 'D'); }}What is the result?
Question ID: UK8291921Given code of Test.java file:package com.examtest.ocp; import java.time.*; public class Test { public static void main(String [] args) { System.out.println(Duration.ofDays(-2)); }}What is the result?
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?
© 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.