File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What class must an inner class extend

 
Cathy Song
Ranch Hand
Posts: 270
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
4Tests website

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.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd pick E. Any class.
 
Mika Leino
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dirk is correct because you can't extend an interface unless you are an interface.
 
Vad Fogel
Ranch Hand
Posts: 504
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is B because the question says must. The only must for classes inheritance is Object, all the rest is optional.
 
mohana konakanchi
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Cathy Song
Ranch Hand
Posts: 270
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all your inputs.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic