top of page
APCSAaday.com
What will the following code segment output?
public class Main {
public static void main(String[] args) {
int[] arr = {5, 10, 15, 20, 25};
int sum = 0;
for(int i = 0; i < arr.length; i += 2)
sum += arr[i];
System.out.println(sum);
}
}
A. 25
B. 30
C. 40
D. 45
What is your answer, don't forget to check out the video explanation at the bottom!
A
B
C
D
Related Posts
Comments
Share Your ThoughtsBe the first to write a comment.
bottom of page