0% found this document useful (0 votes)
4 views5 pages

Java Operators Interview MCQs

The document contains a series of multiple-choice questions (MCQs) related to Java operators, covering topics such as operator precedence, output of expressions, and exception handling. Each question is followed by the correct answer, providing a useful resource for interview preparation. Key concepts include bitwise operations, logical operators, and the behavior of specific expressions in Java.

Uploaded by

Gireesh kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Java Operators Interview MCQs

The document contains a series of multiple-choice questions (MCQs) related to Java operators, covering topics such as operator precedence, output of expressions, and exception handling. Each question is followed by the correct answer, providing a useful resource for interview preparation. Key concepts include bitwise operations, logical operators, and the behavior of specific expressions in Java.

Uploaded by

Gireesh kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Java Operators – Interview MCQs

1. What will be the result of the following code?


int x = 5;
System.out.println(x++ + ++x);

 A. 11
 B. 12
 C. 10
 D. 13

✔ Answer: A. 11

2. Which operator has higher precedence in Java?

 A. ++ (post-increment)
 B. * (multiplication)
 C. << (left shift)
 D. && (logical AND)

✔ Answer: A. ++ (post-increment)

3. What is the output of:


int a = 10;
System.out.println(~a);

 A. 10
 B. -11
 C. -10
 D. Compilation error

✔ Answer: B. -11

4. Which operator is used to compare object references?

 A. ==
 B. equals()
 C. !=
 D. Both A and C

✔ Answer: D. Both A and C


5. What does the expression true & false return?

 A. true
 B. false
 C. Compilation Error
 D. Runtime Error

✔ Answer: B. false

6. What is the result of:


int x = 3;
int y = 2;
System.out.println(x >>> y);

 A. 0
 B. 1
 C. 2
 D. 3

✔ Answer: B. 0

7. What does the instanceof operator do?

 A. Checks if a class is abstract


 B. Creates an instance
 C. Compares two objects
 D. Checks if an object is an instance of a class

✔ Answer: D. Checks if an object is an instance of a class

8. Which of the following is not a valid assignment?

 A. int a = 10 / 2;
 B. int b = 10.5;
 C. double d = 5;
 D. char c = 65;

✔ Answer: B. int b = 10.5;

9. What is the result of:


System.out.println(10 + 20 + "Java" + 10 + 20);

 A. 30Java30
 B. 30Java1020
 C. Java3020
 D. Java102030

✔ Answer: B. 30Java1020

10. Which operator evaluates left to right, even if it’s logical?

 A. &&
 B. ||
 C. &
 D. !=

✔ Answer: C. &

11. How does Java treat the expression (3 + 4 * 2)?

 A. 14
 B. 11
 C. 10
 D. 9

✔ Answer: B. 11

12. What is the output of:


int a = 5, b = 10;
System.out.println((a > b) ? a : b);

 A. 5
 B. 10
 C. true
 D. Compilation error

✔ Answer: B. 10

13. Which of the following is a short-circuit operator?

 A. &
 B. |
 C. &&
 D. ^

✔ Answer: C. &&
14. What will this print?
int x = 5;
System.out.println(x += 2 * 3);

 A. 11
 B. 16
 C. 10
 D. 7

✔ Answer: A. 11

15. What is the result of:


System.out.println(5 >> 1);

 A. 2
 B. 3
 C. 4
 D. 1

✔ Answer: A. 2

16. Which operator is used in method overloading resolution?

 A. ==
 B. +=
 C. instanceof
 D. None (Java uses compile-time type resolution)

✔ Answer: D. None (Java uses compile-time type resolution)

17. Choose the bitwise inclusive OR operator:

 A. &
 B. |
 C. ^
 D. &&

✔ Answer: B. |

18. Which will throw a NullPointerException?

 A. "abc" instanceof String


 B. null instanceof String
 C. null == null
 D. null.equals("abc")

✔ Answer: D. null.equals("abc")

19. What does the expression 10 >> 2 result in?

 A. 5
 B. 2
 C. 3
 D. 10

✔ Answer: A. 2

20. Which of the following statements is true?

 A. a && b evaluates both even if a is false


 B. a & b short-circuits like &&
 C. a || b short-circuits if a is true
 D. a | b short-circuits if a is true

✔ Answer: C. a || b short-circuits if a is true

You might also like