?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Difficult

Integer Min and Max Values

APCSA-VVEFK0

Given the following method:

public static int integerMinMax(int a, int b)
{
    if (a < Integer.MIN_VALUE || b > Integer.MAX_VALUE)
        return 999;
    else
    if (a > Integer.MIN_VALUE && b < Integer.MAX_VALUE)
        return a + b;
    else
    if (a > Integer.MIN_VALUE)
        return a;
    else
    if (b < Integer.MAX_VALUE)
        return b;
    else
        return 0;
}

What is printed to the console when the following segment of code is executed?

System.out.print(integerMinMax(Integer.MIN_VALUE, Integer.MAX_VALUE) + ", ");   
System.out.print(integerMinMax(-20, Integer.MAX_VALUE) + ", ");   
System.out.print(integerMinMax(10, 52) + ", ");   
System.out.print(integerMinMax(Integer.MIN_VALUE, 500));
A
999, -20, 62, -2147483648
B
-2147483648, -20, 62, -2147483648
C
0, -20, 62, 500
D
2147483647, -20, 62, 500
E
0, 2147483627, 62, -2147483148