Java Quiz 7 : Operators II By Tejas Chaudhari - August 30, 2021 FacebookTwitterPinterestWhatsApp Welcome to your Java Quiz 7 : Operators II 1. What will be the output of the following Java program? class bitwise_operator { public static void main(String args[]) { int var1 = 42; int var2 = ~var1; System.out.print(var1 + " " + var2); } } a) 42 42b) 43 43c) 42 -43d) 42 43 2. What will be the output of the following Java program? class bitwise_operator { public static void main(String args[]) { int a = 3; int b = 6; int c = a | b; int d = a & b; System.out.println(c + " " + d); } } a) 7 2b) 7 7c) 7 5d) 5 2 3. What will be the output of the following Java program? class leftshift_operator { public static void main(String args[]) { byte x = 64; int i; byte y; i = x << 2; y = (byte) (x << 2) System.out.print(i + " " + y); } } a) 0 64b) 64 0c) 0 256d) 256 0 4. What will be the output of the following Java program? class rightshift_operator { public static void main(String args[]) { int x; x = 10; x = x >> 1; System.out.println(x); } } a) 10b) 5c) 2d) 20 5. What will be the output of the following Java program? class Output { public static void main(String args[]) { int a = 1; int b = 2; int c = 3; a |= 4; b >>= 1; c <<= 1; a ^= c; System.out.println(a + " " + b + " " + c); } } a) 3 1 6b) 2 2 3c) 2 3 4d) 3 3 6 6. What is the output of relational operators?a) Integerb) Booleanc) Charactersd) Double 7. Which of these is returned by “greater than”, “less than” and “equal to” operators?a) Integersb) Floating – point numbersc) Booleand) None of the mentioned 8. Which of the following operators can operate on a boolean variable? 1. && 2. == 3. ?: 4. +=a) 3 & 2b) 1 & 4c) 1, 2 & 4d) 1, 2 & 3 9. Which of these operators can skip evaluating right hand operand?a) !b) |c) &d) && 10. Which of these statements is correct?a) true and false are numeric values 1 and 0b) true and false are numeric values 0 and 1c) true is any non zero value and false is 0d) true and false are non numeric values 11. What will be the output of the following Java code? class Relational_operator { public static void main(String args[]) { int var1 = 5; int var2 = 6; System.out.print(var1 > var2); } } a) 1b) 0c) trued) false 12. What will be the output of the following Java code? class bool_operator { public static void main(String args[]) { boolean a = true; boolean b = !true; boolean c = a | b; boolean d = a & b; boolean e = d ? b : c; System.out.println(d + " " + e); } } a) false falseb) true turec) true falsed) false true 13. What will be the output of the following Java code? class ternary_operator { public static void main(String args[]) { int x = 3; int y = ~ x; int z; z = x > y ? x : y; System.out.print(z); } } a) 0b) 1c) 3d) -4 14. What will be the output of the following Java code? class Output { public static void main(String args[]) { int x , y = 1; x = 10; if (x != 10 && x / 0 == 0) System.out.println(y); else System.out.println(++y); } } a) 1b) 2c) Runtime error owing to division by zero in if conditiond) Unpredictable behavior of program 15. What will be the output of the following Java code?10. What will be the output of the following Java code?a) 0b) 1c) falsed) true Time is Up!