What is y displayed?

```
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.


b. y is 2.
When evaluating x + x++, x is evaluated first, which is 1. X++ returns 1 since it is post-increment and 2. Therefore y is 1 + 1.

Computer Science & Information Technology

You might also like to view...

When formatting a new Microsoft Word 2016 document, Zoya adjusts the paragraph spacing to 4 points after each paragraph but leaves the line spacing as it was when she originally opened the document. The line spacing on Zoya's Word document is _____.?

A. ?1.08 B. ?2 C. ?2.03 D. ?1

Computer Science & Information Technology

Pressing the ________ key will bring up the Start Menu

Fill in the blank(s) with correct word

Computer Science & Information Technology

The software installation process copies files from the ____ or distribution CD to your PC's hard disk.

A. upload B. download C. remote server D. Internet

Computer Science & Information Technology

Derive exception classes from the class you wrote in the previous exercise. Each new class should indicate a specific kind of error. For example, InvalidHourException could be used to indicate that the value entered for hour was not an integer in the range 1 to 12.

What will be an ideal response?

Computer Science & Information Technology