LearnFrenzy
Sign in Take a free test

Control Flow Statements · Control Flow MCQ · Question 13

Changing array elements in a for-each loop Answer, explanation & discussion

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

for (int x : arr) x = 0; – what happens to arr?

  • A All elements become 0
  • B Nothing – x is a copy of each element Correct
  • C A compile error
  • D An exception
Correct Answer: Option B

Use an index loop to assign elements.

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