LearnFrenzy
Sign in Take a free test

Arrays in Java · Java Arrays MCQ · Question 17

Modifying an array inside a method Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 17 Back to Exercise

A method sets a[0] = 99 on the array it receives. Does the caller see the change?

  • A No, Java is pass-by-value
  • B Yes – the method receives a copy of the reference, which points to the same array Correct
  • C Only for static methods
  • D Only if the array is final
Correct Answer: Option B

Java is pass-by-value, but the value passed is the reference.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links