T T T T
System.out.println(a++ > 10 || ++b <= 21);
System.out.println(" " + a + " " + b);
System.out.println(a > 10 && ++b <= 22);
System.out.println(" " + a + " " + b);
System.out.println(a <= 11 && b == 22);
System.out.println(" " + a + " " + b);
System.out.println(c++ == 31 && a++ == 11 || b++ == 22);
System.out.println(" " + a);
System.out.println(" " + a + " " + b + " " + c);
The expression becomes true || true, which is true.
Value of a after this line: 12
Value of b after this line: 23
Value of c after this line: 31
The answer is D, because both prefix (++a) and postfix (a++) operators kept its result.
E.g:
After the first println
System.out.println(a++ > 10 || ++b <= 21);
The value of a is 11, therefore by the time it reaches the fourth println, a++ would already be 12, not 11.
guys take care the output will be TRUE four times so the answer is C
if you check it on the compiler you will get the same output i mention , because the || operator requires only one to be true.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
___Anu___
7 months, 2 weeks agoaum0201
7 months, 3 weeks agoSabatinoA
8 months agotimecookie
9 months, 3 weeks agoshmilany
10 months agoYousef10
11 months agofalchetto
1 year, 2 months agoim2wishes
1 year, 4 months agoAndalusia
1 year, 4 months agoarjunec1
1 year, 6 months agoarjunec1
1 year, 6 months agoTonter
1 year, 7 months ago