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

Codecs are often bundled together into a single media player program to reduce confusion to the user

Indicate whether the statement is true or false

Computer Science & Information Technology

For two systems to communicate across a TCP/IP network, the system sending thepacket must map the address of the destination computer to the physical or mediaaccess control (MAC) address, which is a unique 12-digit hexadecimal number thatis burned into ROM on every network adapter card. The ________ Protocol detects and updates a table that matches physical addresses with IP addresses

Fill in the blank(s) with correct word

Computer Science & Information Technology