Dan's exam Study Guide/mughal/chapter7/exam1.html Q-14 Which of the follow are true statements. a. An anonymous class can extend only the Object class. b. An anonymous class can not implement an interface. c. An anonymous class can be abstract. d. An anonymous class is implicitly final. e. An anonymous class can be static. f. The class instance creation expression for an anonymous class must never include parameters. g. An anonymous class must declare at least one constructor. h. None of the above. By going through the Mughal book I thought option e is true.
Section 7.1 Overview of Nested Classes- Pg224 Local and anonymous classes can be either static or non-static, where being non-static means that an instance of such a class is associated with an instance of the enclosing class.
But JLS (and according to Dan too) says
15.9.5 Anonymous Class Declarations An anonymous class is never abstract (�126.96.36.199). An anonymous class is always an inner class (�8.1.2); it is never static (�8.1.1, �8.5.2). An anonymous class is always implicitly final (�188.8.131.52).
Can someone let me know what will be the right answer for exam point of view ? Is Khalid Mughal wrong in saying that local and anonymous classes which are defined in static context can be said to be static local and static anonymous classes ?
Shweta, For the purposes of the exam, the JLS is the ultimate authority. I developed my exam questions while reading through the JLS so my questions should be consistent with the JLS. My set of exams that are organized based on the chapters of Khalid's book were organized based on the table of contents that is available at Amazon.com. I have not read Khalid's book so I would not be surprised if you find a few more questions that are not entirely consistent with Khalid's statements. My first set of single topic exams were organized alphabetically. As I added more topics they were just added to the end of the list. Later, I reorganized the topics based on the exam objectives published by Sun, but I soon realized that that organization was not optimal. At that point, I decided that the most useful organization would be one that follows the same sequence as a popular study guide that people are using to study for the exam. (I assume that most of the study guides are similar.) I know that Khalid's book is very popular so I selected that one. Fortunately, the table of contents is available at Amazon so I organized an exam set around it. Although my questions are probably very different from Khalid's, I think my exam set should be very helpful for anyone reading the book or just about any SCJP study guide.
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Joined: Sep 23, 2002
Hi Dan, No doubt, your exams are helping me a lot in my preparation for the exam. Especially the questions in the Study guide order helps understand deeply the topic I had just studied. But sometimes when the book doesn't match with JLS, it really confuses me especially when I don't have that much time or frankly speaking that much patience to go through the JLS topics so deeply. Anyway, I think you are right, the JLS is the ultimate authority !!!