Limited access

Upgrade to access all content for this subject

Consider the following method.

public static int sumUntilGreaterThan(int max)
{
     int sum=0, i=1;
     while(sum<=max)
     {
         sum+=i;
         i++;
     }
     return sum;
}

When calling sumUntilGreaterThan(12), how many times would it execute the body of the while loop?

A

4

B

5

C

6

D

7

E

12

Select an assignment template