Given the code fragment:



if (aVar++ < 10) {
    System.out.println(aVar + " Hello World!");
} else {
    System.out.println(aVar + " Hello Universe!");
}

What is the result if the integer aVar is 9?

A.

10 Hello World!

B.

Hello Universe!

C.

Hello World!

D. Compilation fails.

題解

「++」運算子若放置於變數後面,會先取值才會進行變數值再加一的動作,因此這邊的if條件式會成立,而輸出「10 Hello World!」。