This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I encountered a question from Exam-Lab (truly a great learning tool) that is about overriding a method
the code is as follows
In K & B the exam watch is given that if a method throws a checked exception and the overriding method does not throw any exception then when we call the method from the subclass object but the superclass reference then the compiler complains because it thinks that it is calling the super type of the version (I understood it very well)
but in the above program
method in abstract class AbsA, the method throws a checked exception
this method is being overridden in abstract class AbsB (I found strange ...an abstract method overriding a non abstract method)
Now NonC extends AbsB and then it overrides play() method this time not throwing any exception
now in the main method of MC class we are using AbsA reference to call method play using the object NonC();
but I think this contradicts the rule that is given in K & Bt
this time the compiler does not think that the method getting called is from class AbsA
is it because we have declared it abstract?
or some other reason?
please help I am confused about this
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
could not notice that throws clause there
I thought that the exception is not handled there
my mistake ........
should give more attention to actually READING the questions well
another thing I wanted to say
I am getting about 50% to 55% marks in ExamLab
and after retaking the exam, means be thoroughly going through the concepts of the wrong questions... I am able to get about 80% (not by recalling the answer, by recalling the concepts and the solving the question once again ) in it
I think I am ready for the exam now
Ankit wish me luck for the exam
will take it on 30th June