Author | Topic: inner class |
Umesh ranch hand |
posted April 02, 2000 09:51 AM
Ans: a
|
Howard Stern ranch hand |
posted April 02, 2000 10:25 AM
This question has already been discussed previously. C is indeed a valid answer. However not because B does not extend A. An inner class should not extend the outer class. It is treated as if it is another member of the class A. Only you must remember that you cannot instantiate an inner class without associating it with a reference of the outer class. An inner class is useful when you want to create an object in the context of another object. i.e
In this example the member variable int i of the outer class A shall be assigned the value 10 and the constructor of the inner class shall print "i=10". The member variable of the outer class is accessible from the inner class [This message has been edited by Howard Stern (edited April 02, 2000).]
|
maha anna bartender |
posted April 02, 2000 04:27 PM
However not because B does not extend A. An inner class should not extend the outer class. It is treated as if it is another member of the class A. Howard, I caught you here. An inner class CAN EXTEND outer class / any class as long as it has the access level.
|
Shiva ranch hand |
posted April 03, 2000 11:15 AM
hey, maha anna i was puzzeled why c is not correct, it is thanks for expln,
|
go_mango greenhorn |
posted April 04, 2000 06:35 AM
Another way to think of constructor chaining: I use a model of the grounding of electric circuits. But ofcoarse, it is a grounding of constructor calls. Appears that constructor chaining between superclass and subclass is quite a bit like overriding, that is; the constructor signatures must match. I think of this chaining like grounding. IF so AND an explicit constructor is written AND an implicit no-arg constructor is not provided (as is the case) THEN, a subclass can only chain to its superclass constructor thru the constructor signatures provided. In the case above, the no-arg constructor is not grounded, that is not connected to a superclass constructor. [This message has been edited by go_mango (edited April 04, 2000).]
|
| | |