permaculture playing cards*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Q from DAN's Nested class exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Q from DAN Watch "Q from DAN New topic
Author

Q from DAN's Nested class exam

Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787

Question 8
Which of the follow are true statements.
a. A nested class is any class that is declared within the body of another class or interface.
b. A nested class can not be declared within the body of an interface declaration.
c. A top level class is a class this is not a nested class.
d. An inner class is a nested class that is not static.
e. A nested class can not be declared static.
f. A named class is any class that is not anonymous.
g. None of the above

Answer a is also correct. How can an interface include nested class. I thought interface is only a protocal that defines what will be in implementing classes, without any implementation in itself. If nested class in interface, it has to have implementation...
Thanks
Barkat
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Barkat Mardhani:

How can an interface include nested class. I thought interface is only a protocal that defines what will be in implementing classes, without any implementation in itself. If nested class in interface, it has to have implementation...

If you take a look at the JLS, §9.5 Member Type Declarations you'll see:

Interfaces may contain member type declarations (�8.5). A member type declaration in an interface is implicitly static and public.

It's true that any methods defined within an Interface are implicitly abstract and therefore have no definition, but an Interface is also capable of containing a nested class. That class, on the other hand may have fully defined methods within it.
I hope that helps,
Corey


SCJP Tipline, etc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Q from DAN's Nested class exam
 
Similar Threads
inner class in an Interface declaration
Public class in file
Nested Class
Inner class terminology
Abstract Method