Java MCQ: Which of the following is true about data types in Java?
Answer:
Explanation:
Java supports two main categories of data types: primitive data types and reference data types. Primitive data types include int
, char
, float
, boolean
, and others, which are not objects and are stored directly in memory. Reference data types include objects and arrays, which store references (addresses) to the actual data.
Primitive data types are typically stored on the stack, while objects and arrays are stored on the heap. Java does not restrict data types to integers; it supports a variety of data types, including floating-point numbers, characters, and booleans.
Understanding the distinction between primitive and reference data types is crucial for effective memory management and program optimization in Java.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html