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
We can walk to school together. And we can both read this tiny ad:
Become a Java guru with IntelliJ IDEA

This thread has been viewed 1097 times.

All times above are in ranch (not your local) time.
The current ranch time is
Mar 22, 2019 12:41:21.