Q5: What are Primitive Data Types versus Reference Types in Java?

  • Primitive Types (8 total): byte, short, int, long, float, double, char, boolean. They store raw binary values directly on the stack or inline inside heap objects.
  • Reference Types: Objects, Arrays, Interfaces, and Enums. They store memory addresses (references) pointing to heap-allocated object instances.
Key Takeaways
  • Primitives hold raw values directly; Reference types hold memory address references to heap objects.
  • Primitives cannot be null; Reference variables default to null.
Knowledge Check

Which of the following is NOT a Java primitive data type?