[Logo]
Forums Register Login
abstract class problem
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
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 ]
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss


This thread has been viewed 426 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jul 20, 2018 20:22:32.