Operators and Assignments Questions and Answers

Practice Mode
Showing 10 of 38 questions
Q21
int a = 4; int b = a-- + 2; What is b?
  • A 5
  • B 6
  • C 4
  • D 2
Answer: Option B
Explanation: Post-decrement returns old value: b = 4 + 2 = 6.
Q22
Which operator checks object equality?
  • A ==
  • B =
  • C equals()
  • D !=
Answer: Option C
Explanation: equals() checks value equality (for objects).
Q23
What is the result of true ^ false?
  • A true
  • B false
  • C 1
  • D 0
Answer: Option A
Explanation: XOR returns true if operands differ.
Q24
int a = 2, b = 3; System.out.println(a | b);
  • A 1
  • B 2
  • C 3
  • D 3
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?
  • A >>
  • B >>>
  • C <<
  • D ><
Answer: Option A
Explanation: >> preserves the sign bit.
Q26
What is the value of int x = 9; x %= 4;?
  • A 1
  • B 2
  • C 3
  • D 4
Answer: Option A
Explanation: 9 % 4 = 1.
Q27
Which operator is used for conditional evaluation?
  • A ??
  • B ::
  • C ?:
  • D $
Answer: Option C
Explanation: Ternary operator uses ?:.
Q28
int a = 5, b = 10; boolean c = a < b && a != b;What is c?
  • A false
  • B true
  • C 0
  • D Compilation error
Answer: Option B
Explanation: Both conditions are true -> result true.
Q29
What is the output of "2" + 3 + 4?
  • A 234
  • B 9
  • C 7
  • D 34
Answer: Option A
Explanation: String concatenation: "2"+"3" = "23" then "234".
Q30
Which operator in Java is right-associative?
  • A +
  • B %
  • C =
  • D >>
Answer: Option C
Explanation: Assignment operators evaluate right-to-left.
Questions and Answers for Competitive Exams Various Entrance Test