3.What class must an inner class extend: A. The top level class B. The Object class C. Any class or interface D. It must extend an interface
The answer given is C. I think the answer should be B. Since it is not necessary for the inner class to extend a class or implement an interface. Am I right? Thanks.
I'd say C is correct, because the group Any class or interface includes Object. The way I understand option B is "An inner class must extend the Object class.", and that would force us to extend all inner classes from Object.
3. What class must an inner class extend: A. The top level class B. The Object class C. Any class or interface D. It must extend an interface
Anonimous InnerClass should extend atleast one class or implement atleast one interface. Where as for inner class with name it's not manditory to extends any class(By default extends Object) or implement an interface. Since anonimous inner Class also an inner class,Both B and C are correct. If we go by words "extend" and "implement:, Question askes for extend only so B is correct. I guess I am confused with ambious quesiton itself. May we need a GURU now.
Answer: the question is poorly worded and needs to be rewritten. One of the problems with the mock exams is that they haven't gone through the same level of quality control as the real thing. Don't expect to get poorly worded questions like that one on the real test.