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.
Joined: May 06, 2011
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: