When an array is passed to a method, what does the method receive?

Java MCQ: When an array is passed to a method, what does the method receive?

a) The reference of the array
b) A copy of the array
c) Length of the array
d) Copy of the first element

Answer:

a) The reference of the array

Explanation:

When an array is passed to a method in Java, the method receives the reference to the array, not a copy of the array. This means changes made to the array inside the method will affect the original array.

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