
Antony Deepak B. answered 02/10/22
Senior Software Engineer Specialized in Java
The initial version of Java is developed from C Language. When you create an object in Java internally it creates them in the Heap (a type of Memory space) and the reference or pointer is returned which assigned to the variable.
For example: Car c = new Car(); here the car object is created and the reference value is stored in variable c.
We can verify this by printing the variable in the console.
Java by default pass all data (Primitive data types - int, float, double,.....etc.) by value only objects are passed by reference. So, when we pass the object only the reference is passed not the entire object.