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

Java Operators Advanced MCQs Set2

The document contains 20 advanced multiple-choice questions (MCQs) focused on Java operators, relevant for Oracle Java Certifications and common interview patterns. Each question is followed by the correct answer, covering topics such as operator overloading, bitwise operations, and logical expressions. The questions test knowledge of Java syntax and operator functionality.

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 views4 pages

Java Operators Advanced MCQs Set2

The document contains 20 advanced multiple-choice questions (MCQs) focused on Java operators, relevant for Oracle Java Certifications and common interview patterns. Each question is followed by the correct answer, covering topics such as operator overloading, bitwise operations, and logical expressions. The questions test knowledge of Java syntax and operator functionality.

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/ 4

🧠 Java Operators – 20 Advanced MCQs

(Set 2)
Based on Oracle Java Certifications & Common Interview Patterns

1. What is the result of:


System.out.println(10 + "20" + 30);
A. 60
B. 102030
C. 1030
D. 1020
✅ Answer: B. 102030

2. Which of the following is NOT a valid use of the ternary operator?


A. int x = (a > b) ? a : b;
B. boolean b = (true) ? false : true;
C. String s = true ? "yes" : 1;
D. char c = (1 == 1) ? 'A' : 'B';
✅ Answer: C. String s = true ? "yes" : 1;

3. What is the output of:


int a = 1;
int b = 2;
System.out.println(a | b);
A. 0
B. 1
C. 3
D. 2
✅ Answer: C. 3

4. Which operator cannot be overloaded in Java?


A. +
B. instanceof
C. !=
D. >>>
✅ Answer: B. instanceof

5. Which expression gives the same result as x *= y + z?


A. x = x * y + z
B. x = x * (y + z)
C. x = y + z * x
D. x = x + y * z
✅ Answer: B. x = x * (y + z)

6. What will 5 ^ 3 evaluate to?


A. 1
B. 6
C. 2
D. 4
✅ Answer: B. 6

7. What does a >>> b mean?


A. Arithmetic right shift
B. Bitwise AND
C. Logical right shift
D. Modulus division
✅ Answer: C. Logical right shift

8. What will this print?


System.out.println(true | false);
A. false
B. true
C. 1
D. Compilation Error
✅ Answer: B. true

9. Which operator is used to perform a bitwise exclusive OR?


A. &&
B. ||
C. ^
D. &
✅ Answer: C. ^

10. What does the expression (x = 3) == 3 evaluate to?


A. true
B. false
C. Compilation error
D. Runtime exception
✅ Answer: A. true

11. What will the following output?


System.out.println(4 << 1);
A. 2
B. 4
C. 8
D. 6
✅ Answer: C. 8

12. Which one is a valid use of the modulus operator?


A. 10 % 3
B. 10 %% 3
C. 10 mod 3
D. mod(10, 3)
✅ Answer: A. 10 % 3

13. What is the precedence of == compared to +?


A. Higher
B. Lower
C. Equal
D. Depends on usage
✅ Answer: B. Lower

14. Which operator is used to perform logical AND with short-circuiting?


A. &
B. &&
C. and
D. |
✅ Answer: B. &&

15. What is the result of this expression?


System.out.println((true || false) && false);
A. true
B. false
C. Compilation Error
D. Exception
✅ Answer: B. false

16. What is printed?


int x = 2;
int y = 3;
System.out.println(x & y);
A. 2
B. 3
C. 0
D. 1
✅ Answer: D. 1

17. Which operator returns true if both operands are not equal?
A. ==
B. !==
C. !=
D. ^=
✅ Answer: C. !=

18. Which operator is used to cast a value to a lower type?


A. ()
B. cast
C. ->
D. &
✅ Answer: A. ()

19. Which result will you get from 10 / 0 in Java?


A. 0
B. Infinity
C. Compilation Error
D. ArithmeticException
✅ Answer: D. ArithmeticException

20. What does the following print?


System.out.println(4 ^ 4);
A. 0
B. 8
C. 4
D. 1
✅ Answer: A. 0

You might also like