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!