aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes classes(inner, nested) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "classes(inner, nested)" Watch "classes(inner, nested)" New topic
Author

classes(inner, nested)

Aru
Ranch Hand

Joined: Jul 20, 2000
Posts: 112
Hi All,
Can someone explain & Answer the following ?
Which of the following statements is true?
a) An interface can contain a nested top-level inner class.
b) An interface can contain a member inner class.
c) A member inner class can implement an interface.
d) A static method can contain a local class.
e) A static method can contain a nested top-level class.

Thx in Advance.
Aruna
Uvnik Gupta
Ranch Hand

Joined: Jul 24, 2000
Posts: 32
All are true !!!
Correct me if I am wrong.
rajsim
Ranch Hand

Joined: May 31, 2000
Posts: 116
>>e) A static method can contain a nested top-level class.
a method can only contain local or anonymous class
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Also-
b) An interface can contain a member inner class.
No, an interface can only contain a static member class, formerly known as a top-level nested class (which is probably what answer a) was trying to refer to). All classes defined in an interface are implicitly static and public.

"I'm not back." - Bill Harding, Twister
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Can anyone let me know which are the right answers.
thankx
shanks
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Since Rahul and I explained what's wrong with e and b, the remaining answers are correct:
a, c, d
kevin jia
Ranch Hand

Joined: Jul 13, 2000
Posts: 38
Hi,
I don't agree your point. Although a member inner class within an interface is implicitly public and static, but in forms it is a member, how could we call this form of inner class.
For example:
public interface A {
class inner { }
}
There is a problem of nature language, but not Java language.
Originally posted by Jim Yingst:
Since Rahul and I explained what's wrong with e and b, the remaining answers are correct:
a, c, d

 
 
subject: classes(inner, nested)