This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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?
I am trying to download examlab scjp 6 test , however i keep getting error file not found.Would appreciate if someone could help me.
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.
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: