This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I know Exception class is a sub class of Throwable class, where Throwable overrides the toString() method of Object class, and that toString() returns the Exception details in the form of a String.
Whats my doubt is.. does the ArithmeticException(or for that matter any class that inherits Exception) class override the toString() again?
I have a sample code here,
This gave me the output
That means while printing 'e' the Exception version of toString() method is called.. right?
But one of my instructors told me that there will be an overriden version of toString() in every class that inherits Exception.. like ArithmeticException, ArrayOutOfBoundsException.. etc. I guess he is wrong..
Am I correct? or Am I wrong.. please correct me.. Thankyou
As far as I know each of the subclasses of Throwable will inherit the toString() method and it would return a concatenation of three strings: name of the actual class of this object+": " (a colon and a space)+output of getMessage() method for this object.