MCQs on Operators and Expressions | Java Operators

Arithmetic Operators

  1. What will be the result of the expression 10 % 3 in Java?
    • a) 1
    • b) 3
    • c) 10
    • d) 0
  2. Which operator is used for exponentiation in Java?
    • a) ^
    • b) **
    • c) pow()
    • d) Java does not have an exponentiation operator
  3. What will be the result of the expression 7 / 2 in Java?
    • a) 3.5
    • b) 4
    • c) 3
    • d) 0
  4. What is the result of 5 + 2 * 3 in Java?
    • a) 11
    • b) 16
    • c) 15
    • d) 21
  5. What will be the value of x after the following expression: int x = 5 + 10 * 3;?
    • a) 15
    • b) 30
    • c) 35
    • d) 50

Relational Operators

  1. What will the result of the expression 5 == 5 be in Java?
    • a) true
    • b) false
    • c) 1
    • d) 0
  2. Which operator is used to check if two values are not equal in Java?
    • a) !=
    • b) ==
    • c) <>
    • d) !==
  3. What is the result of the expression 10 > 5 in Java?
    • a) true
    • b) false
    • c) 1
    • d) 0
  4. Which of the following operators is used for greater than or equal to in Java?
    • a) <=
    • b) >=
    • c) >
    • d) <
  5. What will be the result of 5 != 4 in Java?
    • a) true
    • b) false
    • c) 1
    • d) 0

Logical Operators

  1. Which operator is used for logical AND in Java?
    • a) &
    • b) &&
    • c) ||
    • d) |
  2. What is the result of true && false in Java?
    • a) true
    • b) false
    • c) 1
    • d) 0
  3. What does the || operator do in Java?
    • a) Logical AND
    • b) Logical OR
    • c) Logical NOT
    • d) None of the above
  4. What will be the result of the expression !(true && false) in Java?
    • a) true
    • b) false
    • c) 1
    • d) 0
  5. Which operator is used for logical NOT in Java?
    • a) !
    • b) &&
    • c) ||
    • d) ~

Assignment and Unary Operators

  1. What does the += operator do in Java?
    • a) It divides two values and assigns the result to the left operand
    • b) It adds two values and assigns the result to the left operand
    • c) It performs modulo operation and assigns the result
    • d) It assigns the value of the right operand to the left operand
  2. Which of the following is the correct syntax to increment the value of x by 1 in Java?
    • a) x++
    • b) ++x
    • c) x += 1
    • d) All of the above
  3. What will the expression x++ return if x = 5 in Java?
    • a) 6
    • b) 5
    • c) 4
    • d) 0
  4. What is the effect of x-- when x = 10 in Java?
    • a) x becomes 9
    • b) x becomes 11
    • c) x becomes 10
    • d) x becomes 0
  5. What will be the value of x after x = 5; x *= 2; in Java?
    • a) 5
    • b) 10
    • c) 7
    • d) 15

Combining Operators

  1. What will be the result of 5 + 3 * 2 in Java?
    • a) 16
    • b) 11
    • c) 10
    • d) 8
  2. What will be the result of the expression 10 / 3 + 2 in Java?
    • a) 4
    • b) 5
    • c) 3
    • d) 6
  3. Which of the following expressions will result in a syntax error in Java?
    • a) 5 = x
    • b) x + y = 10
    • c) 5 == x
    • d) x != y
  4. What is the result of the expression 4 * 5 / 2 in Java?
    • a) 10
    • b) 20
    • c) 8
    • d) 2
  5. Which of the following is the correct result of the expression true || false && false in Java?
    • a) true
    • b) false
    • c) true && false
    • d) true && true

Unary Operators

  1. Which of the following operators in Java is used to change the sign of a number?
    • a) +
    • b) -
    • c) !
    • d) ++
  2. Which of the following is a correct use of the ++ operator in Java?
    • a) int x = 3; x++;
    • b) int x = 3; ++x;
    • c) x = x + 1;
    • d) All of the above
  3. In Java, what is the output of the following code snippet?csharpCopy codeint x = 4; System.out.println(--x);
    • a) 5
    • b) 4
    • c) 3
    • d) 0
  4. Which operator is used for bitwise negation in Java?
    • a) !
    • b) ~
    • c) ^
    • d) &
  5. What does the following expression evaluate to in Java: x = 10; y = 20; x = ++y;?
    • a) 10, 20
    • b) 21, 20
    • c) 20, 21
    • d) 20, 10

Answer Key:

QnoAnswer
1a) 1
2d) Java does not have an exponentiation operator
3c) 3
4a) 11
5c) 35
6a) true
7a) !=
8a) true
9b) >=
10a) true
11b) &&
12b) false
13b) Logical OR
14a) true
15a) !
16b) It adds two values and assigns the result to the left operand
17d) All of the above
18b) 5
19a) x becomes 9
20b) 10
21b) 11
22a) 4
23a) 5 = x
24a) 10
25a) true
26b) -
27d) All of the above
28c) 3
29b) ~
30c) 20, 21

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top