AP® Computer Science A

Free Version

Upgrade subject to access all content

Easy

Increment Operators Used As Parameters

APCSA-S6YVBE

Consider the following method.

public static void preAndPost(int x)
{
    if (x < 3)
        System.out.print(x);
    else
        System.out.print(++x);
    if (x < 2)
        System.out.print(x);
    else
        System.out.print(x++);
    if (x < 1)
        System.out.print(x);
    else
        System.out.print(++x);
    if (x < 0)
        System.out.print(x);
    else
        System.out.print(x++);
    System.out.print(x);
}

Which of the following is printed as a result of the call preAndPost(2)?

A

22445

B

23455

C

23345

D

23445

E

34566