What is the result?

Given the code fragment:
<code>
int b = 4;
b — ;
System.out.println (– b);
System.out.println(b);
</code>

What is the result?

Given the code fragment:

int b = 4;
b -- ;
System.out.println (-- b);
System.out.println(b);

What is the result?

A.
2 2

B.
1 2

C.
3 2

D.
3 3

Explanation:

Variable b is set to 4.
Variable b is decreased to 3.
Variable b is decreased to 2 and then printed. Output: 2
Variable b is printed. Output: 2



Leave a Reply 1

Your email address will not be published. Required fields are marked *