So we all know java .reference .It is an address that indicates where an object’s variables and methods are stored. Java spec says :

Just before a reference to the newly created object is returned as the result, the indicated constructor is processed to initialize the new object 

And most common example given is something like below:

                                                                                                          
  @author: åminur                                                                                         
                                                                                                          
 ------------------------------------------------------                                                   
  PART 1: Assignment of object, points to reference.                                                      
 ------------------------------------------------------                                                   
     1. Emp tmpEmp = new Emp();                                                                           
     2. Emp e1 = tmpEmp;                                    +---------------------------+                 
        //cause both e1 and e2 points        tmpEmp ------->|                           |                 
        //to same object i.e e1 just                        | object created at line 1  |                 
        //starts pointing to tmpEmp          emp ---------->|                           |                 
                                                            |                           |                 
                                                            +---------------------------+                 
                                                                                                          
                                                                                                          
    // Hence any change in tmpEmp                                                                         
    // e.g tmpEmp.empId                                                                                   
    // will change e1.empId too as it's                                                                   
    // technically same object.                                                                           
                                                                                                          
 

However surprisingly, recently I found that a few are not aware of the 2nd part of it. They assume any change in tempEmp will always reflect in e1, even when tempEmp’s reference has been nulled/or changed. Something like this this.

                                                                                                          
 --------------------------------------------------------------                                           
 PART 2 : Which a couple of folks couldn't answer in interview.                                           
 --------------------------------------------------------------                                           
     3. tmpEmp = new Emp(); // or tmpEmp=null;                                                            
                                                                                                          
     // Here tmpEmp got a new reference.                                                                  
     // But this does not mean e1's reference has also changed.                                          
     // Any reassignment to new Object, or to null reference                                              
     // unhooks the two objects.                                                                          
                                                                                                          
                           +---------------------------+                                                  
          tmpEmp --------> |object created at line 3   |                                                  
                           +---------------------------+                                                  
                           +---------------------------+                                                  
          e1 ------------> |object created at line 1   |                                                  
                           +---------------------------+