Two Laptop Bag*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dan Chisholm Comprehensive Exam#1 Q#5 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 "Dan Chisholm Comprehensive Exam#1 Q#5" Watch "Dan Chisholm Comprehensive Exam#1 Q#5" New topic
Author

Dan Chisholm Comprehensive Exam#1 Q#5

Chris Gastin
Ranch Hand

Joined: Aug 13, 2002
Posts: 51
I got this answer right because I have seen this question in dan's topic exams, but I do not understand. Could someone go into a little more detail on why the answer is "E".
Thanks
Chris G.


Chris Gastin<br />SCJP 1.4<br />SCWCD 1.3
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
Originally posted by Chris Gastin:
I got this answer right because I have seen this question in dan's topic exams, but I do not understand. Could someone go into a little more detail on why the answer is "E".
Thanks
Chris G.

The instance initializer of class R invokes method P.m1. The throws clause of method P.m1 declares that P.m1 throws an Exception. Therefore, every constructor of class R must also have a throws clause that declares Exception.
Please see the
Java Language Specification, Section 8.6, Instance Initializers.
An instance initializer of a named class may not throw a checked exception unless that exception or one of its superclasses is explicitly declared in the throws clause of each constructor of its class and the class has at least one explicitly declared constructor. An instance initializer in an anonymous class (�15.9.5) can throw any exceptions.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
 
GeeCON Prague 2014
 
subject: Dan Chisholm Comprehensive Exam#1 Q#5