Forums Register Login

overiding abstract methods????

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
 


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.
+Pie Number of slices to send: Send
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...
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
i think someone needs to modify the rules round up games question regarding overiding abstract methods.

who is the creator of the game anyways ???
Hey! You're stepping on my hand! Help me tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 816 times.
Similar Threads
Why it is illegal to use abstract and static modifiers together in method declaration ?
Question in JavaRanch Roundup
overriding
Methods
Method Overriding
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:01:31.