Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Correct Inner Class....

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What might form part of correct inner class declaration and installation?
A. new simpleInterface(){}
B. new complexInterface(x) {}
C. private final abstract class c
D. MyClass extends OtherClass
E. new MyClass() extends OtherClass{}
The answer is A,B,
Can anybody explain why E is not an answer?
Thanx
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think e is also the correct answer. inner class has the freedom
of extending any class.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tian,
This question is about the construct of anonymous classes.
For defining and instantiating an anonymous class, use the following syntax:
new superclassName ( optional arg list ){ ...... }
NO extends clause is used in the construct!

Hopes this help!
Erin
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I got it.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
new MyClass() extends OtherClass{} is not correct because
new MyClass() is not a class it is merely an object of MyClass. And an object cannot extend a class
 
Mohit pundir
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tian:
What might form part of correct inner class declaration and installation?
A. new simpleInterface(){}
B. new complexInterface(x) {}
C. private final abstract class c
D. MyClass extends OtherClass
E. new MyClass() extends OtherClass{}
The answer is A,B,
Can anybody explain why E is not an answer?
Thanx


I got confused about option B ,
Can we have constructors for Interface.
or
B. new complexInterface(x) {}
Exan any one explain me how this works?
Thanx
Mohit
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic