Hello sumit
well what are we doing here?
we are declaring the reference variable m1 of type Mixer
and we are creating object with Mixer m2 = new Mixer();
Now m1 is the instance variable isn't it?
now we can access instance variables of the class using class objects isn't it ?
suppose there is an instance variable int i ;
how do we refer to it if we have object m2?
we refer to it as m2.i
right?
or suppose
we have a instance variable of type Integer
that is
Integer i;
and we can refer to it as m2.i;
in the program
let us go step by step
we are creating the object
also
what happened here? m3 object is created and as we are pasisng m2 to the constructor it is assigned to the reference variable m1 through constructor initialization
and hence m1 is pointing to object of m2() isn't it?
now
m3.m1 will point to the object pointed by m2
and m5.m1 will point to null as m1 is not initialized
Hope this is clear now sumit
Happy coding