First, the question asks about a an object of type "Inner," but the type is actually Outer.Inner. Because the nested class is static, it can be instantiated without an instance of the outer class, so (if we assume type Outer.Inner) C is correct...
Outer.Inner i = new Outer.Inner();
The second problem is more serious. As defined in section 8.1.3 of the JLS, "An inner class is a nested class that is not explicitly or implicitly declared static." So in this example, "Inner" is not really an inner class. More than just being misleading, this turns out to be key to the answer.
You might expect that it would be possible to instantiate Outer.Inner using an instance of Outer, as in option A. In fact, this was possible prior to Java 1.4, but it now gives a compilation error of "qualified new of static class." This was reported as a bug, but Sun closed it as "not a bug," citing section 15.9.1 of the JLS: "It is a compile-time error if Identifier [in this case, "Inner"] is not the simple name (�6.2) of an accessible (�6.6) non-abstract inner class (�8.1.2)..."
In other words, because Inner is static, it is not an inner class, and therefore cannot be instantiated using an instance of the enclosing class.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database