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
posted
0
All are true !!! Correct me if I am wrong.
rajsim
Ranch Hand
Joined: May 31, 2000
Posts: 116
posted
0
>>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: 18670
posted
0
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
posted
0
Can anyone let me know which are the right answers. thankx shanks
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
posted
0
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
posted
0
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
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.