Exam Permalink:
https://www.jobilize.com/java-certification-questions
Question Permalink:
https://www.jobilize.com/how-to-handle-java-unchecked-exceptions
Question 31 / 297:  What is the expected output of compiling and running this code?
class Father {

public Father() throws RuntimeException {

System.out.print("Father");

throw new RuntimeException();

}

}

class Son extends Father {

public Son() throws RuntimeException {

System.out.print("Son");

}

}

public class Tester {

public static void main(String[] args) {

new Son(); // line 17

}

}

A  Compile error, an import to java.lang.RuntimeException is required
B  Father will be printed then a RuntimeException would be thrown
C  Compile error at line 17, new Son() should be within a try/catch block
D  Son
E  SonFather
F  FatherSon
<< First < Previous Next > Last >>
Explanation:

Implicit call to super() will be called, print Father, then throws a RuntimeException. The remaining of the code in Son constructor won't be continued.

RuntimeException is an unchecked exception which means Son() although that it explicitly declares to throw a RuntimeException, no handling is required

Exam Home Page
https://www.jobilize.com/java-certification-questions

Oracle Certified Professional Java Programmer

Author:

Access: Public Instant Grading

Ask
Dewey Compton
Start Exam
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>