- Aobjects
- Bobject references
- Cprimitive data type
- DNone of the above
Time Taken:
Correct Answer:
Wrong Answer:
Percentage: %
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.
This line of Java code creates a new array of characters called "c" with a length of 5.
The "new" keyword is used to allocate memory for the array, and the "char[]" indicates that it is an array of characters. The number inside the square brackets [] specifies the size of the array, which in this case is 5.
So, the resulting variable "c" is an array that can hold up to 5 characters. Note that the elements of the array are initially set to the default value of the char data type, which is '\0' (the null character).
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.