What is an array in Java?

Java MCQ: What is an array in Java?

a) A collection of elements of different types
b) A collection of elements of the same type
c) A single object
d) A variable

Answer:

b) A collection of elements of the same type

Explanation:

An array in Java is a collection of elements of the same type, stored in a contiguous block of memory. Arrays can hold primitive data types or objects and are indexed, starting from 0.

Understanding arrays is crucial for handling multiple values efficiently in Java, especially when the size of the collection is fixed.

Reference links:

https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top