Emilio Botella

+ Follow
since Sep 06, 2004
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Emilio Botella

A inner clas has a special relation between one instance of the containing class and its own instance.
With new Inner() the first answer can accomplish this rule because within the method in line 3 exits the needed instance of Outer. (called this)

In the other hand, a static method (line 8) doesn't know instances so answer B is wrong. (If answer B was: o.new Inner(); or new Outer().new Inner(); then B would be rigt too)

Answer c hasn't got appropiate syntax.
Answer d is made thinking about static inner classes.
The type (time compiler) of b is Beta interface so compiler is upset that there isn't any method called testIt() in Beta.

You should put in String testIt(); in Beta and implement it with public access in the class.
Inner class has name so you can create a constructor with its name.
Anonymous inner class hasn't name, but you can use initializer blocks

Anonymous class has the constructor provided by compiler.

References: Java in a nutshell
The problem with answer c is it hasn't got a return type.
In static block you've declarated a local variable, you may use it within a loop, for example to initiate others static variables.
Static methods belong to a class. If a instance inherits static method only can share it with others so a instance can`t override a static method.