aspose file tools
The moose likes Beginning Java and the fly likes abstract class problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "abstract class problem" Watch "abstract class problem" New topic
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
    
    9
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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: abstract class problem
 
Similar Threads
removing duplicates from the list?
Use of method local inner class being abstract...
Polymorphic Method Call
How do I extend an abstract inner class
Anonymous -Q