Operators and Assignments Questions and Answers

Practice Mode
Showing 10 of 38 questions
Q31
What is the result of !(5 > 3 && 2 < 1)?
  • A true
  • B false
  • C 1
  • D 0
Answer: Option A
Explanation: Inner: (true && false) -> false, !false = true.
Q32
What does a >>> 2 perform?
  • A Signed right shift
  • B Unsigned right shift
  • C Left shift
  • D XOR operation
Answer: Option B
Explanation: >>> shifts right without sign extension.
Q33
What is the value of byte b = (byte) 130;?
  • A 130
  • B -126
  • C 126
  • D -128
Answer: Option B
Explanation: 130 overflows byte (range -128 to 127): wraps to -126.
Q34
What is the size of the boolean type?
  • A 1 bit
  • B 8 bits
  • C JVM dependent
  • D 16 bits
Answer: Option C
Explanation: JVM does not specify bit size for boolean storage.
Q35
What is printed?System.out.println(10 == 10.0);
  • A true
  • B false
  • C Compilation error
  • D Runtime error
Answer: Option A
Explanation: int 10 promoted to double -> values equal.
Q36
Which of these is not a valid assignment?
  • A int a = 10;
  • B char c = "a";
  • C double d = 20;
  • D float f = 2.5f;
Answer: Option B
Explanation: char uses single quotes ''''a'''', not double quotes.
Q37
System.out.println(7 >> 1);
  • A 3
  • B 3.5
  • C 6
  • D 14
Answer: Option A
Explanation: Right shift divides by 2: 7 >> 1 = 3.
Q38
int a = 5; int b = 2; double c = a / b; What is c?
  • A 2
  • B 2.0
  • C 2.5
  • D 2.50
Answer: Option B
Explanation: Integer division gives 2; stored as 2.0 in double.
Questions and Answers for Competitive Exams Various Entrance Test