| Author |
abstract class problem
|
Mahesh Barik
Greenhorn
Joined: Aug 14, 2006
Posts: 15
|
|
I have a problem with the following;I request you to go through the code abstarct class X { abstract void a1(); abstract void a2(some parameter); // // } abstract class Y extends X { abstract void a1() { //some code; } some code... for a2() etc public static void main(String args[]) { How can I access a1() here?? } } I cannot create an object of Y here; How can I access a1() inside class Y note: I am not using any other class (like class C extends Y etc...) any one please help me to sort out the above problem. Thanks
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
|
|
If you've implemented a1 and a2 in Y, why are you declaring it abstract ? If it is abstract because there are other abstract methods declared in it, then you need to declare another (non-abstract) class that extends Y and implements all the methods. You can then create an instance of this class and call the a1 method. If there is no reason to make Y abstract, then remove the abstract keyword and you will be able to create an instance of it. [ August 18, 2006: Message edited by: Joanne Neal ]
|
Joanne
|
 |
 |
|
|
subject: abstract class problem
|
|
|