Java Practice Test – 2 Posted by Editor Date 2022-09-28 Comments 0 comment Welcome to your Java Practice Test - 2 Which component is responsible for converting bytecode into machine specific code? a) JVM b) JDK d) JRE Which of the following is a valid declaration of an object of class Hyd? a) Hyd obj = new Hyd(); b) Hyd obj = new Hyd; c) obj = new Hyd(); d) new Hyd obj; Which of this statement is incorrect? a) switch statement is more efficient than a set of nested ifs b) two case constants in the same switch can have identical values c) switch statement can only test for equality, whereas if statement can evaluate any type of boolean expression d) it is possible to create a nested switch statements Which component is used to compile, debug and execute java program? a) JVM a) JVM c) JIT d) JRE What would be the output of the following code snippet if variable a=10? if(a<=0) { if(a==0) { System.out.println("1 "); } else { System.out.println("2 "); } } System.out.println("3 "); a) 1 2 b) 2 3 c) 1 3 d) 3 What would be the output of the following code class Hyd { public static void main(String args[]) { int x = 9; if (x == 9) { int x = 8; System.out.println(x); } } } a) 9 b) 8 c) Compilation error d) Runtime error What is true about a break? a) Break stops the execution of entire program b) Break halts the execution and forces the control out of the loop c) Break forces the control out of the loop and starts the execution of next iteration d) Break halts the execution of the loop for certain time frame What will be the output of the following Java program? class Test { public static void main(String args[]) { int a = 5; int b = 10; first: { second: { third: { if (a == b >> 1) break second; } System.out.println(a); } System.out.println(b); } } } a) 5 10 b) 10 5 c) Compile Time Error d) 10 Decide the output of the following Java code? class Test { 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 64 b) 64 0 c) 0 256 d) 256 0 What will be the output of the following Java program? class RightShift { public static void main(String args[]) { int x; x = 10; x = x >> 2; System.out.println(x); } } a) 10 b) 5 c) 2 d) 20 Time is Up! Time's up Share: Editor Previous post Java Practice Test - 1 2022-09-28 Next post UI Technologies Practice Test - 2 2022-09-28 You may also like Oracle Tutorial Videos 8 April, 2023 Spring Tutorial Videos 8 April, 2023 Ui Technologies Tutorial Videos 1 April, 2023