- Aobjects
- Bobject references
- Cprimitive data type
- DNone of the above
In Java, arrays are objects. This means they are instances of the Object
class, and their properties can be accessed through methods that apply to all objects. They store elements of a specific data type (like int
, char
, String
, etc.), and their size is fixed once they are created.
Option A: objects (Correct) Arrays in Java are actual objects, regardless of the type of elements they store. This is why you can access array methods like length
, and arrays are stored in heap memory.
Option B: object references While individual elements of an array might be object references (if the array contains objects), the array itself is not just a reference but an actual object.
Option C: primitive data type Arrays are not primitive data types. Primitive data types in Java are int
, char
, boolean
, double
, etc.
Option D: None of the above This option is incorrect, as arrays are indeed objects in Java.
Answer: a) Arrays can store only objects and not primitive types.
Explanation: This statement is not true. Java arrays can store both objects and primitive types.