LearnFrenzy
Sign in Take a free test

Arrays in Java · Java Arrays MCQ · Question 19

Where are Java arrays stored? Answer, explanation & discussion

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

Where does the JVM store the elements of int[] a = new int[1000]; declared inside a method?

  • A On the stack, like the local variable
  • B On the heap – arrays are objects; the local variable a only holds a reference Correct
  • C In the method area
  • D In a CPU register
Correct Answer: Option B

The array lives as long as something references it, and the garbage collector frees it afterwards.

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