class Mixer {
Mixer() { }
Mixer(Mixer m) { ml = m;}
Mixer m1;
public static void main(String[] args) {
Mixer m2 = new Mixer();
Mixer m3 = new Mixer(m2); m3.go();
Mixer m4 = m3.m1; m4.go();
Mixer m5 = m2.m1; m5.go();
}
void go() { System.out.print("hi "); }
}
What is the result?
hi
hi hi
hi hi hi
Compilation fails
hi, followed by an exception
hi hi, followed by an exception
answer is this
F is correct. The m2 object's m1 instance variable is never initialized, so when m5 tries to use it a NullPointerException is thrown.
but i am getting this
E:\kb>e:\jdk1.5.0\bin\javac Mixer.java
Mixer.java:3: cannot find symbol
symbol : variable ml
location: class Mixer
Mixer(Mixer m) { ml = m;}
^
1 error
E:\kb>
What is write