File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes overiding abstract methods???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "overiding abstract methods????" Watch "overiding abstract methods????" New topic

overiding abstract methods????

Jigar Gosar
Ranch Hand

Joined: Jul 09, 2002
Posts: 95
can an abstract method be overridden???

rules round up says it must, it has no choice!!!

but when the method is not defined in first place, how can it be overridden,

i mean, what is overidden??? since there is no code that is overidden???

please comment.

Regards,<br />Jigar Gosar (SCJP 1.4)<br />visit: <a href="" target="_blank" rel="nofollow"></a>
Chandra Sekhar
Ranch Hand

Joined: Sep 26, 2003
Posts: 90
An abstract method can be thought of as a "template" or "blueprint" for a

method whose implementational details are contained in the sub-classes of

the class in which the abstract method is defined. The implementational

detail is included in the normal way so no changes need to be made to the

class definitions . In effect the abstract method is overriden

by the full method definitions contained in the sub-classes.



"Luck is when opportunity meets preparation"
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608

rules round up says it must

Well, close, but not entirely correct.
Any non-abstract subclass must override any supertype abstract method. This includes abstract methods of superclasses, and implemented interface methods (which are implicitly abstract).

My guess is that you are receiving a compile-time error about failure to implement an abstract method in a supertype that you can't seem to locate.

I assure you, the compiler is right - you'll have to provide more specific information to receive a more detailed answer.

Tony Morris
Java Q&A (FAQ, Trivia)
necati sekkeli

Joined: Jun 21, 2004
Posts: 26
Simply you must create a new class that starts like
public <your-class name> extends <abstract-class-name>
and define all the methods of the abstract class. So you can cast it anywhere like this abstract class.
This is the only advantage...
Jigar Gosar
Ranch Hand

Joined: Jul 09, 2002
Posts: 95
my problem is only with terminology

i have been programming in java over three years.

i have alredy prepared for my certification, and my sjcp exam date is 3rd july.

my problem is only with the term "overiding".
for non-abstract methods the term is fine.
but for abstract method, which has no code or implementation in first place, how can the term overiding can be used when we are not overiding any code, any behaviour. So i think the more appropriate term would be implementing abstract methods, rather than overiding abstract method.

i only want to hear the other side of the story, and want justification of , why my argument is wrong, and the one of rules roundup right.

Tony Jackson
Ranch Hand

Joined: Feb 23, 2001
Posts: 45

You are right. I went to the source (The Java Language Specification, Second Edition) and on page 91, in Section 6.4.2, "The Members of a Class Type", it says:

If the method not inherited is abstract, then the new declaration is said to implement it; if the method not inherited is not abstract, then the new declaration is said to override it.

Jigar Gosar
Ranch Hand

Joined: Jul 09, 2002
Posts: 95
i think someone needs to modify the rules round up games question regarding overiding abstract methods.

who is the creator of the game anyways ???
I agree. Here's the link:
subject: overiding abstract methods????
It's not a secret anymore!