Question 30 / 297:  What is the expected output?
import java.io.IOException;

class Father {

public Father() throws IOException {

System.out.print("Father");

throw new IOException();

}

}

class Son extends Father {

public Son() throws IOException {

System.out.print("Son");

}

}

public class Tester {

public static void main(String[] args) {

try {

new Son();

} catch (IOException e) {

System.out.print("Inside catch");

}

}

}

A  Compile error, constructors can't throw Exceptions
B  FatherSon
C  FatherInside catch
D  Father, then an IOException is thrown
E  Son
F  SonInside catch
<< First < Previous Next > Last >>
Explanation:

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

Exam Home Page
Ask
Yacoub Jayoghli
Start Quiz
Marion Cabalfin
Start Test
Stephanie Redfern
Start Quiz
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>