Consider the following program:
class Outer {/*w w w . j a v a 2s. com*/ class Inner { public void print() { System.out.println("Inner: print"); } } } class Main { public static void main(String []args) { // Stmt#1 inner.print(); } }
Which one of the following statements will you replace with //Stmt#1
to make the program compile and run successfully to print "Inner: print" in console?.
Inner()
;Inner()
;Outer()
.Inner()
;Outer()
.new Inner()
;d)
option d) uses the correct syntax for instantiating outer and Inner classes.
the other three options will result in compiler error(s).