Which of the following are valid to be placed at xxxxxxx ? a) new Inner() b) new Outer().new Inner() c) this.Inner()
class Outer { class Inner { public void method(String i) { System.out.println("eeeee"); } } public static void main(String [] args) { Inner i = xxxxxxxxx } } pleasw explain
YARRAM SREENIVASA REDDY
Greenhorn
Joined: Aug 18, 2000
Posts: 1
posted
0
In the above question you send the correct answer is new Outer().new Inner() The first one you cannot use because you need the instance of enclosing class when you want to create the instance of inner class so you need it . One Imp thing is that when your inner class is given static you can directly instantiate the inner class in static methods of enclosing class. The last one is directly you can throw it out because u cannot use this keyword in static methods. Please reply back me your feelings whether you satisfied or not. I am the new member in this group please send my reference to all. My mail i.d is sreddyy@yahoo.com ------------------
<BR>
Micheal Zhao
Greenhorn
Joined: Aug 28, 2000
Posts: 4
posted
0
new Outer().new Inner() I think the right question is : Outer.Inner i = new Outer().new Inner(). if use Inner i , it will be a compiler error. Micheal
deekasha gunwant
Ranch Hand
Joined: May 06, 2000
Posts: 396
posted
0
Hi, the correct answer is new Outer().new Inner(); regards deekasha