| Author |
abstract method
|
itisha jain
Greenhorn
Joined: Oct 04, 2005
Posts: 11
|
|
"A subclass of a class with an abtract method must provide n implementation for the abstract method". The statement is given as false in khalid mughal.the explanation being... Abstract methods foma superclass need not be implemented by a subclass.The subclass must then b declared abstract. however,i thought the statement is true.Plz explain
|
 |
Lalitha Gottumukkula
Ranch Hand
Joined: May 24, 2005
Posts: 45
|
|
Hope an example makes the point clearer.....
|
 |
A Kumar
Ranch Hand
Joined: Jul 04, 2004
Posts: 973
|
|
HI, Have a look ...
|
 |
Akshay Kiran
Ranch Hand
Joined: Aug 18, 2005
Posts: 220
|
|
This should make it clearer abstract class Abstract{ // A class with an abstract method abstract void doThis(); } abstract class A extends Abstract{ // extends abstract but provides no implementation, and hence decld. abstract } class B extends Abstract{ // B extends Abstract, but provides no implementation AND is NOT abstract // The compiler throws an error } Therefore, a subclass of a class with an abstract method must either be declared abstract or must provide an implementation of the abstract method. I put that phrase in bold because, it is only true for classes that have abstract methods, and not necessarily abstract classes in general. abstract class A{ void someMethod(){} } class B extends A{ // not abstract, doesn't override the someMethod of A // no problem }
|
"It's not enough that we do our best; sometimes we have to do<br />what's required."<br /> <br />-- Sir Winston Churchill
|
 |
 |
|
|
subject: abstract method
|
|
|