0

The differences between Object type and reference type?

Actually which one will hold the address of an instance object? Thanks!

23rd Apr 2020, 9:24 AM
KH Wong
KH Wong - avatar
1 Odpowiedź
+ 2
Object obj = new Object(); Here new Object() is the actual object that is created in the heap. Whereas obj is a reference variable of type Object which is stored in the stack and points or holds the memory location of the newly created object.
23rd Apr 2020, 12:01 PM
Avinesh
Avinesh - avatar