aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Problem/ Failure in Practice Exams Book (java 6) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Problem/ Failure in Practice Exams Book (java 6)" Watch "Problem/ Failure in Practice Exams Book (java 6)" New topic
Author

Problem/ Failure in Practice Exams Book (java 6)

moritz mueller
Greenhorn

Joined: Jan 21, 2010
Posts: 7
i hope this / those problems doesn't occur.
It is question 29 of 2nd practice exam:

Given that:
Exception is the superclass of IOException, and
IOException is the superclass of FileNotFoundException, and
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 of the following methods, inserted independently at line 11, compiles? (Choose all
that apply.)
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; }

Answer:
B, C, D, and F are correct....


My answer was / would be C and F - because the method call "new Feynman().think();" doesn't declares or handles an exception. So B and D do cause an compile error. What do you think?
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

moritz mueller wrote:
My answer was / would be C and F - because the method call "new Feynman().think();" doesn't declares or handles an exception. So B and D do cause an compile error. What do you think?

you are correct. probably author over looked in to that line ( but I think author intention is about checking overriding rule ).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem/ Failure in Practice Exams Book (java 6)