Junior — Middle
How much memory does an object of type reference occupy in Java?
sobes.tech AI
Answer from AI
In Java, an object reference occupies a fixed amount of memory, which depends on the JVM architecture and platform. Usually, on 32-bit systems, a reference takes 4 bytes, and on 64-bit systems — 8 bytes. When using compressed oops (Compressed OOPs), which is common on 64-bit JVMs with limited memory, the size of a reference can be 4 bytes. Therefore, the exact size of a reference depends on the specific JVM and its settings, but it is usually 4 or 8 bytes.