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

static inner class

 
joshua antony
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question :
Given the following class file , how can you get a reference to an object of type Inner ?

class Outer {

// some valid lines of code

static class Inner {
//some more valid lines of code
}
}

Options :

a . new Outer ( ) . new Inner ( )
b . Outer . new Inner ( )
c . new Outer . Inner ( )
d . Outer . Inner ( )

Answer is a and c.
I can understand c, but why a?
Since the inner class is static, it should not have outer class instance enclosing it, isint it?
 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only c is correct.
Where from you got this quesion and answer?
Also write a small program with this code and try yourself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic