File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes static inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "static inner class" Watch "static inner class" New topic

static inner class

joshua antony
Ranch Hand

Joined: Jun 05, 2006
Posts: 117
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

Joined: Jul 04, 2006
Posts: 236
Only c is correct.
Where from you got this quesion and answer?
Also write a small program with this code and try yourself.
I agree. Here's the link:
subject: static inner class
It's not a secret anymore!