Explore what CodeHS has to offer for districts, schools, and teachers.
Click on one of our programs below to get started coding in the sandbox!
View All
Given the following values of arr and the mystery method, what will the values of arr be after you execute: mystery()?
arr
mystery
mystery()
private int[] arr = {1, 2, 3, 4, 5};
public void mystery() { for (int number : arr) { number *= 2; } }
{3, 4, 5, 6, 7}
{2, 4, 6, 8, 10}
{5, 4, 3, 2, 1}
{2, 2, 2, 2, 2}
{1, 2, 3, 4, 5}