Java Quiz 8 : Operators III & Control Statements By Tejas Chaudhari - August 31, 2021 FacebookTwitterPinterestWhatsApp Welcome to your Java Quiz 8 : Operators III & Control Statements 1. Which of these have highest precedence?a) ()b) ++c) *d) >> 2. What should be expression1 evaluate to in using ternary operator as in this line? expression1 ? expression2 : expression3a) Integerb) Floating – point numbersc) Booleand) None of the mentioned 3. What is the value stored in x in the following lines of Java code? int x, y, z; x = 0; y = 1; x = y = z = 8;a) 0b) 1c) 9d) 8 4. What is the order of precedence (highest to lowest) of following operators? 1. & 2. ^ 3. ?:a) 1 -> 2 -> 3b) 2 -> 1 -> 3c) 3 -> 2 -> 1d) 2 -> 3 -> 1 5. Which of these statements are incorrect?a) Equal to operator has least precedenceb) Brackets () have highest precedencec) Division operator, /, has higher precedence than multiplication operatord) Addition operator, +, and subtraction operator have equal precedence 6. What will be the output of the following Java code? class operators { public static void main(String args[]) { int var1 = 5; int var2 = 6; int var3; var3 = ++ var2 * var1 / var2 + var2; System.out.print(var3); } } a) 10b) 11c) 12d) 56 7. What will be the output of the following Java code? class operators { public static void main(String args[]) { int x = 8; System.out.println(++x * 3 + " " + x); } } a) 24 8b) 24 9c) 27 8d) 27 9 8. What will be the output of the following Java code? class Output { public static void main(String args[]) { int x=y=z=20; } } a) compile and runs fineb) 20c) run time errord) compile time error 9. Which of these lines of Java code will give better performance? 1. a | 4 + c >> b & 7; 2. (a | ((( 4 * c ) >> b ) & 7 ))a) 1 will give better performance as it has no parenthesesb) 2 will give better performance as it has parenthesesc) Both 1 & 2 will give equal performanced) Dependent on the computer system 10. What will be the output of the following Java program? class Output { public static void main(String args[]) { int a,b,c,d; a=b=c=d=20 a+=b-=c*=d/=20 System.out.println(a+" "+b+" "+c+" "+d); } } a) compile time errorb) runtime errorc) a=20 b=0 c=20 d=1d) none of the mentioned 11. Which of these selection statements test only for equality?a) ifb) switchc) if & switchd) none of the mentioned 12. Which of these are selection statements in Java?a) if()b) for()c) continued) break 13. Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?a) do-whileb) whilec) ford) none of the mentioned 14. Which of these jump statements can skip processing the remainder of the code in its body for a particular iteration?a) breakb) returnc) exitd) continue 15. Which of this statement is incorrect?a) switch statement is more efficient than a set of nested ifsb) two case constants in the same switch can have identical valuesc) switch statement can only test for equality, whereas if statement can evaluate any type of boolean expressiond) it is possible to create a nested switch statements Time is Up!