cana class extend a class which is jar and added to a classpath

I have to extend a class which is in different package or which is in server.jar. Is that possible?
I am using eclipse, it does say its not finding parent class.
cutie_smilyAsked:
Who is Participating?
 
CEHJCommented:
It can extend any class that's loadable. To be loadable it must be on your classpath so add the jar to your Build Path (Add jars)
0
 
ksivananthCommented:
as long as you have added server.jar in the Libraries list and the class has the right access( public ), you can
0
 
cutie_smilyAuthor Commented:
Thanks everybody
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
cutie_smilyAuthor Commented:
Base class Animal
sub class cow

Animal a=new cow();
a.speak(); //it says Animal does not have speak method.

Doesn't it get from subclass ?
0
 
CEHJCommented:
Animal should have it as a method (abstract)
0
 
objectsCommented:
Its only possible if the class is not final. If the class is not declared as final then you aref ree to subclass it

> Base class Animal
> sub class cow
> Animal a=new cow();
> a.speak(); //it says Animal does not have speak method.

> Doesn't it get from subclass ?


Need to either use:

cow a = new cow();

or cast it:

((cow)a).speak();

or add a speak() method to the Animal class

0
 
ksivananthCommented:
>>Doesn't it get from subclass ?

If the method exist only in the subclass, there is no way the Animal class can point to that method which it not aware of, try object's comment.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.