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 InnerClass Question/ Exam Lab 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 "InnerClass Question/ Exam Lab" Watch "InnerClass Question/ Exam Lab" New topic

InnerClass Question/ Exam Lab

Minu Sam

Joined: Apr 26, 2012
Posts: 10
Please see code below

I had a question since in the static method there is no this reference.I should not be even able to have a reference type of Engine.
It doesnt give a compilation error.However if i try to instantiate as in

it gives compilation error which makes sense.But why would the first case compile.I was thinking that i always need to access the inner class from a static method as OuterClassName.InnerClassMName, isnt that true?

Question 2:

I am trying to download examlab scjp 6 test , however i keep getting error file not found.Would appreciate if someone could help me.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

static method expect static members for a class[or member can access via instance of a class using *new* key word, constructors are implicitly static]. however it wont mind about declaring class reference, it minds only about instance member of a class with out static reference/ new keyword.

Sarah Rising
Ranch Hand

Joined: May 06, 2011
Posts: 38
1) The reason it fails to compile after you try to create an object of type Engine is because each Engine object needs an associated AirJet object. So an AirJet object must be created first, then the AirJet object can be used to create an Engine object, like this:

2) The reason your first compile attempt does not fail is that the compiler has no reason yet for it to fail. It can't predict if you'll correctly create an Engine object later. For example, like this:

I agree. Here's the link:
subject: InnerClass Question/ Exam Lab
It's not a secret anymore!