Unit 2 · Selection and Iteration
Accumulators and Counters
Accumulators and Counters MCQ Practice
Question 1 of 15
Answered 0 of 15
Choose one answer.
What is printed by the following code segment?
public class AccumulatorsAndCountersContext
{
public static void runExample()
{
int sum = 0;
for (int i = 1; i <= 4; i++)
{
sum += i;
}
System.out.print(sum);
}
public static void main(String[] args)
{
runExample();
}
}