Hi,
I just found question in OCP Practise Exams book:
Exam 2, Q:29:
3. import java.io.*;
4. class Physicist {
5. void think() throws IOException {}
6. }
7. public class Feynman extends Physicist {
8. public static void main(
String[] args) {
9. new Feynman().think();
10. }
11. // insert method here
12. }
Which compiles?
A. void think() throws Exception {}
B. void think() throws FileNotFoundException {}
C. public void think() {}
D. protected void think() throws IOException {}
E. private void think() throws IOException {}
F. void think() { int x = 7/0; }
I mark C and F as correct answers. But in book as correct answes is marked B, C, D and F.
How could be B and D correct? They throw an exception , but in main() method is not declared that it could throw exception, so I think that B and D could not be true.
Please somebody explain me what's going on here.