I have a task to predict output of the program without printing it.
In this program person did not overwritte toString() method and variant of output
Exception in thread "main"
java.lang.MethodNotFoundException
and the second one is
cannot resolve symbol
symbol: method toString ()
What is difference between these 2?
The former is a runtime exception, the second is a compile an error that won’t allow your code to run in the first place. Neither of these should come up if you run a toString method without overriding it unless you define an explicit class hierarchy in which you have a class throwing the former exception then have one of its children fail to override it.