Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exam Q on Bill Brogden site

 
Rajinder Yadav
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check all correct answers
a) An inner class can have the same name as its enclosing class.
b) An instance of a non static inner class always has an associated instance of the enclosing class
c) An anonymous inner class is always assumed to extend Object.
Ans: b)
I choose b,c why is c not a correct answer?
 
Erik Dark
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the name implies, anonymous inner classes have no name. Instead the use the name of the class that they subclass which can be any class...
Beware that because of this way of declaration they do not use extends!
Erik Dark
[ February 24, 2002: Message edited by: Erik Dark ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many uses of anonymous inner classes in fact extend classes like event adapters or Thread. That is what I was trying to bring out in that question.
Bill
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same question has been asked 2 days ago, please check it:
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=24&t=014925
 
Rajinder Yadav
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone for helping me clear up my confusion!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic