Consider this program to answer the following question:
class Shape { public Shape() { System.out.println("Shape constructor"); }//from w ww . j a va 2 s.co m public class Color { public Color() { System.out.println("Color constructor"); } } } class Main { public static void main(String []args) { Shape.Color black = new Shape().Color(); // #1 } }
What will be the output of the program?
Color()
is undefined for the type Shape.A.
You need to create an instance of outer class Shape in order to create an inner class instance.