What is y displayed in the following code?
```
public class Test {
public static void main(String[] args) {
int x = 1;
int y = x++ + x;
System.out.println("y is " + y);
}
}
```
a. y is 1.
b. y is 2.
c. y is 3.
d. y is 4.
c. y is 3.
When evaluating x++ + x, x++ is evaluated first, which does two things: 1. returns 1 since it is post-increment. x becomes 2. Therefore y is 1 + 2.
You might also like to view...
A generic class
A) can only extend a class that is also generic B) can extend generic and non-generic classes C) can only extend a non generic class D) cannot extend any class
You can press ____ to open the Actions panel in Windows.
A. [Esc] B. [Alt][%] C. [F9] D. [Ctrl][A]
If an individual day is edited on the calendar, the day's number is ____.
A. bold B. italicized C. underlined D. in red
________ improves hard-disk performance by anticipating data needs and reducing time to access data from secondary storage.
A. Formatting B. File decompression C. Disk caching D. RAID