Forums Register Login

I just wanted to know what is wrong in the above code ?
It is throwing this error : Exception in thread "main" java.lang.Error: Unresolved compilation problem
An error like "unresolved compilation problem" probably means that you have some old *.class files somewhere and that the compiler gets confused. Delete all your *.class files and re-compile everything again.

What is wrong: Look at lines 2 and 5. What do you think could be wrong there?
i think overriding of same functions is not possible in same class....am i correct??
Yes. Overriding can only be done by subclasses.
You are doing overloading not overriding.

mallikarjun don wrote:You are doing overloading not overriding.

He is doing neither.
(1 like)
You have two doit() methods - the same name, the same arguments. When you call doit() (without arguments) on an A object, how is Java supposed to know which of the two to call?
oh,my god.you define tow same methos in the same class.
if you want override a method.you first have to inherit another class.
Welcome to the Ranch
to Campbell Ritchie
thank you so much. nice to meet you.
You're welcome
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 976 times.

All times above are in ranch (not your local) time.
The current ranch time is
Apr 20, 2018 03:06:58.