Operators and Assignments Questions and Answers
Practice ModeShowing 10 of 38 questions
Q21
int a = 4; int b = a-- + 2; What is b?
Answer: Option B
Explanation: Post-decrement returns old value: b = 4 + 2 = 6.
Q22
Which operator checks object equality?
Answer: Option C
Explanation: equals() checks value equality (for objects).
Q23
What is the result of true ^ false?
Answer: Option A
Explanation: XOR returns true if operands differ.
Q24
int a = 2, b = 3; System.out.println(a | b);
Answer: Option C
Explanation: Bitwise OR: 2 (10) | 3 (11) = 3 (11).
Q25
Which operator is used to shift bits to the right with sign extension?
Answer: Option A
Explanation: >> preserves the sign bit.
Q26
What is the value of int x = 9; x %= 4;?
Answer: Option A
Explanation: 9 % 4 = 1.
Q27
Which operator is used for conditional evaluation?
Answer: Option C
Explanation: Ternary operator uses ?:.
Q28
int a = 5, b = 10; boolean c = a < b && a != b;What is c?
Answer: Option B
Explanation: Both conditions are true -> result true.
Q29
What is the output of "2" + 3 + 4?
Answer: Option A
Explanation: String concatenation: "2"+"3" = "23" then "234".
Q30
Which operator in Java is right-associative?
Answer: Option C
Explanation: Assignment operators evaluate right-to-left.