Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

overiding abstract methods????

 
Jigar Gosar
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Thanks.
 
Chandra Sekhar
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

rgds

Chandrasekhar
SCJP
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
necati sekkeli
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks.
 
Tony Jackson
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jigar,

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.

Tony
 
Jigar Gosar
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think someone needs to modify the rules round up games question regarding overiding abstract methods.

who is the creator of the game anyways ???
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic