Given:
class Main { /*from w ww. ja v a2 s. co m*/ Main() { } Main(Main m) { m1 = m; } Main m1; public static void main(String[] args) { Main m2 = new Main(); Main m3 = new Main(m2); m3.go(); Main m4 = m3.m1; m4.go(); Main m5 = m2.m1; m5.go(); } void go() { System.out.print("hi "); } }
What is the result?
F is correct.
The m2 object's m1 instance variable is never initialized, so when m5 tries to use it a NullPointerException is thrown.