The output is 100 100 1 1 1. When we pass the reference variable h1, the copy of bits that refer to the object referred to by h1 on heap are passed to the method doStuff(). Correct? Then why is it printing 100 again for h1 roomNr? It should print 1 .