Welcome to your Test - 2 Unique Test Code - 819 Name Email Phone 1. Question: You are creating an acme.db module. This module contains a com.acme.DB class that will be used by other modules of your application. Which of the following files correctly defines the acme.db module?Select 1 option(s): module acme.db{ exports com.acme/DB;} module acme.db{ exports com.acme.*;} module acme.db{public com.acme;} module acme.db{ exports com.acme.DB; } module acme.db{ exports com.acme; } module acme.db{ exports com.acme to *;}2. Question: Which of the following code fragments is/are appropriate usage(s) of generics? Select 2 option(s): Map< String, List< String > > myMap = new HashMap(); List< String > list = new ArrayList<>(); list.add("A");list.addAll(new ArrayList<>()); List< String > list = new ArrayList<>();list.add("A"); List< ? extends String > list2 = new ArrayList<>();list.addAll(list2); List<> list = new ArrayList();3. Question: Which of the following options correctly create an ExecutorService instance? Select 1 option(s): var es = ExecutorService.getInstance(); var es = new ExecutorService(); var es = Executors.newFixedThreadPool(2); var es = Executor.getSingleThreadExecutor(); var es = Executors.getSingleThreadExecutor();4. Question: What will the following code print when compiled and run? public class TestClass{ public static void main(String[] args) { System.out.println(getMsg((char)10)); } public static String getMsg(char x){ String msg = "Input value must be "; msg = msg.concat("smaller than X"); msg.replace('X', x); String rest = " and larger than 0"; msg.concat(rest); return msg; }}Select 1 option(s): Input value must be smaller than X and larger than 0 Input value must be smaller than 10 and larger than 0 Input value must be smaller than X Input value must be smaller than 105. Question: What will the following program print when compiled and run?class Game{ public void play() throws Exception{System.out.println("Playing...");}}public class Soccer extends Game{public void play(){ System.out.println("Playing Soccer...");}public static void main(String[] args){Game g = new Soccer();g.play();}}Select 1 option(s): It will not compile. It will throw an Exception at runtime. Playing Soccer... Playing... None of these.6. Question: How will you initialize a SimpleDateFormat object so that the following code will print the full text time zone of the given date? System.out.println(sdf.format(new Date()));Select 1 option(s): SimpleDateFormat sdf = new SimpleDateFormat("tttt", Locale.FRANCE); SimpleDateFormat sdf = new SimpleDateFormat("T", Locale.FRANCE); SimpleDateFormat sdf = new SimpleDateFormat("z", Locale.FRANCE); SimpleDateFormat sdf = new SimpleDateFormat("zzzz", Locale.FRANCE); SimpleDateFormat sdf = new SimpleDateFormat("XXX", Locale.FRANCE);7. Question: A java source file contains the following code:interface I {int getI(int a, int b); }interface J{int getJ(int a, int b, int c);}abstract class MyIJ implements J , I { } class MyI{int getI(int x, int y){ return x+y; } }interface K extends J{int getJ(int a, int b, int c, int d);} Identify the correct statements:Select 1 option(s): It will fail to compile because of MyIJ It will fail to compile because of MyIJ and K It will fail to compile because of K It will fail to compile because of MyI and K It will fail to compile because of MyI and K It will compile without any error.8. Question: Which of the following commands can be used to run a class named com.foo.Bar, which is part of a module named foo.bar packaged in foobar.jar (Assume that the jar file is located in the current directory.)Select 1 option(s): java --classpath foobar.jar --module foo.bar/com.foo.Bar java --module foobar.jar foo.bar/com.foo.Bar java --classpath foobar.jar --module-path foo.bar/com.foo.Bar java --module-path foobar.jar com.foo.Bar java --module-path foobar.jar --module foo.bar/com.foo.Bar9. Question: Checked exceptions are meant for...Select 1 option(s): exceptional conditions external to an application that a well written application should anticipate and from which it can recover. exceptional conditions external to the program that a well written program cannot anticipate but should recover from. exceptional conditions from which recovery is difficult or impossible. exceptional situations internal to an application that the application can anticipate but cannot recover from.10. Question: Which of the given statements are correct for a method that overrides the following method: public Set getSet(int a) {...}Assume that Set is an interface and HashSet is a class that implements Set.Select 3 option(s): Its return type must be declared as Set. It may return HashSet. It can declare any Exception in throws clause It can declare any RuntimeException in throws clause. It can be abstract.11. Question: What will the following code print? public class Test{ public static void stringTest(String s){ s.replace('h', 's'); } public static void stringBuilderTest(StringBuilder s){ s.append("o"); } public static void main(String[] args){ String s = "hell"; StringBuilder sb = new StringBuilder("well"); stringTest(s); stringBuilderTest(sb); System.out.println(s + sb); }}Select 1 option(s): sellwello hellwello hellwell sellwell None of these.12. Question: Given ://1public class TestClass {//2 public static void main(String... args) throws Exception{ List al = new ArrayList(); printElements(al); }//3 static void printElements(List... la) { for(List l : la){ System.out.println(l); } }}Which option will get rid of compilation warnings for the above code?Select 1 option(s): Apply @SafeVarargs at //1 Apply @SafeVarargs at //2 Apply @SafeVarargs at //3 Apply @SafeVarargs at //2 as well as //3. None of the above.13. Question: Consider the following program :class Test{ public static void main(String[] args){ short s = 10; // 1 char c = s; // 2 s = c; // 3 }}Identify the correct statements.Select 2 option(s): Line 3 is not valid. Line 2 is not valid. It will compile because both short and char can hold 10. None of the lines 1, 2 and 3 is valid.14. Question: Identify correct statements regarding Java module system.Select 1 option(s): The file in which module information is specified must be named moduleinfo.java. Module information can also be specified using @Module annotation Every class of a module must specify which module it belongs to either using @Module annotation or using a command line option. module-info.java must list all packages that you want to add to that module. The only information required in the file that specifies module information is the module name.15. Question: What can be inserted in the code below so that it will print true when run? public class TestClass{ public static boolean checkList(List list, Predicate<List> p){ return p.test(list); } public static void main(String[] args) { boolean b = //WRITE CODE HERE System.out.println(b); }}Select 2 option(s): checkList(new ArrayList(), al -> al.isEmpty()); checkList(new ArrayList(), ArrayList al -> al.isEmpty()); checkList(new ArrayList(), al -> return al.size() == 0); checkList(new ArrayList(), al -> al.add("hello")); checkList(new ArrayList(), (ArrayList al) -> al.isEmpty());16. Question: What will be the result of attempting to compile and run the following program? public class TestClass{ public static void main(String args[ ] ){ Object a, b, c ; a = new String("A"); b = new String("B"); c = a; a = b; System.out.println(""+c); }}Select 1 option(s): The program will print java.lang.String@XXX, where XXX is the memory location of the object a. The program will print A The program will print B The program will not compile because the type of a, b, and c is Object. The program will print java.lang.String@XXX, where XXX is the hash code of the object a.17. Question: Given the following class:public class SpecialPicker<K>{ public K pickOne(K k1, K k2){ return k1.hashCode()>k2.hashCode()?k1:k2; } }what will be the result of running the following lines of code: SpecialPicker<Integer> sp = new SpecialPicker<>(); //1 System.out.println(sp.pickOne(1, 2).intValue()+1); //2Select 1 option(s): The first line of code will not compile. The second line of code will not compile. It will throw an exception at run time. It will print 3.18. Question: Given the following class:public class Food{ // LINE 1 String name; int caloriesPerServing; public Food(String name, int calories){ this.name = name; this.caloriesPerServing = calories; } //accessors not shown //LINE 2}This class is used in an application as follows -ArrayList<Food> al = new ArrayList<>();//code that adds Food objects to al not shownCollections.sort(al);What changes must be done to Food class so that the call to Collections.sort(al) will work as expected?Select 2 option(s): Replace line 1 with : public class Food implements Comparable{ Replace line 1 with :public class Food implements Comparator{ Replace line 1 with :public class Food extends Comparator< Food >{ Replace line 1 with :public class Food extends Comparable< Food >{ Add the following a line 2 : public int compareTo(Food f){return this.name.compareTo(f.name); } Add the following a line 2 : public boolean compare(Food f){ return this.name.compare(f.name); } Add the following a line 2 :public int compare(Food f){return this.name.compare(f.name); }19. Question: What will the following code print? var flag = true; if(flag = false){ System.out.println("1"); }else if(flag){ System.out.println("2"); }else if(!flag){ System.out.println("3"); }else System.out.println("4");Select 1 option(s): 1 2 3 4 Compilation error.20. Question; What will the following code print? List s1 = new ArrayList( );s1.add("a");s1.add("b");s1.add("c");s1.add("a");if(s1.remove("a")){ if(s1.remove("a")){ s1.remove("b"); }else{ s1.remove("c"); }}System.out.println(s1);Select 1 option(s): [b] [c] [b, c, a] [a, b, c, a] Exception at runtime21. Question: You are writing a class named Bandwidth for an internet service provider that keeps track of number of bytes consumed by a user. The following code illustrates the expected usage of this class -class User{ Bandwidth bw = new Bandwidth(); public void consume(int bytesUsed){ bw.addUsage(bytesUsed); } ... other irrelevant code }class Bandwidth{ private int totalUsage; private double totalBill; private double costPerByte; //add your code here ...other irrelevant code}Your goal is to implement a method addUsage (and other methods, if required) in Bandwidth class such that all the bandwidth used by a User is reflected by the totalUsage field and totalBill is always equal to totalUsage*costPerByte. Further, that a User should not be able to tamper with the totalBill value and is also not able to reduce it.Which of the following implementation(s) accomplishes the above?Select 1 option(s): public void addUsage(int bytesUsed){ if(bytesUsed>0){totalUsage = totalUsage + bytesUsed;totalBill = totalBill + bytesUsed*costPerByte; }} protected void addUsage(int bytesUsed){ totalUsage += bytesUsed; totalBill = totalBill + bytesUsed*costPerByte; } private void addUsage(int bytesUsed){ if(bytesUsed>0){ totalUsage = totalUsage + bytesUsed; totalBill = totalUsage*costPerByte; }} public void addUsage(int bytesUsed){ if(bytesUsed>0){totalUsage = totalUsage + bytesUsed;}} public void updateTotalBill(){totalBill = totalUsage*costPerByte;}22. Question: Assuming that STOCK table exists and is empty, what will the following code snippet print?String qr = "insert into STOCK ( ID, TICKER, LTP, EXCHANGE ) values( ?, ?, ?, ?)";try(PreparedStatement ps = c.prepareStatement(qr);){ ps.setInt(1, 111); ps.setString(2, "APPL"); ps.setDouble(3, 0.0); ps.setString(4, "NYSE"); int i = ps.executeUpdate(); //1 System.out.println(i);}Select 1 option(s): It will not compile due to error at //1. It will print 0. It will print 1. It will print 4. It will print -1.23. Question: Given the following code, which of the constructors shown in the options can be added to class B without causing a compilation to fail (independent of each other)?class A{ int i;public A(int x) { this.i = x; } }class B extends A{ int j;public B(int x, int y) { super(x); this.j = y; } }Select 2 option(s): B( ) { } B(int y ) { j = y; } B(int y ) { super(y*2 ); j = y; } B(int y ) { i = y; j = y*2; } B(int z ) { this(z, z); }24. Question: Given the following code:interface Movable{ int offset = 100; public void move(int dx);}interface Growable{ public void grow(int dy);}class Animal implements Movable, Growable{ public void move(int dx){ } public void grow(int dy){ }}Select 1 option(s): Animal class illustrates Java's support for multiple inheritance of type. Animal class illustrates Java's support for multiple inheritance of state. Animal class illustrates Java's support for multiple inheritance of type as well as state. Animal class illustrates Java's support for multiple implementation inheritance.25. Question: What will the following program print?class Test{ public static void main(String args[]){ int var = 20, i=0; do{while(true){ if( i++ > var) break;} }while(i<var--);System.out.println(var); }}Select 1 option(s): 19 20 21 22 It will enter an infinite loop. It will not compile due to the variable named var.26. Question: A novice java programmer is unable to get a file named Coffee.java compiled. It contains the following enum definition:public enum Coffee //1{ ESPRESSO("Very Strong"), MOCHA, LATTE; //2 public String strength; //3 Coffee(String strength) //4 { this.strength = strength; //5 } public String toString(){ return strength; } //6}Which line is causing the problem?Select 1 option(s): 1 2 3 4 5 627. Question: What will be the result of attempting to compile and run the following program? public class TestClass{ public static void main(String args[ ] ){ A o1 = new C( ); B o2 = (B) o1; System.out.println(o1.m1( ) ); System.out.println(o2.i ); }}class A { int i = 10; int m1( ) { return i; } }class B extends A { int i = 20; int m1() { return i; } }class C extends B { int i = 30; int m1() { return i; } }Select 1 option(s): The program will fail to compile. Class cast exception at runtime. It will print 30, 20. It will print 30, 30. It will print 20, 20.28. Question: What will be the result of compilation and execution of the following code ? IntStream is1 = IntStream.range(0, 5); //1OptionalDouble x = is1.average(); //2System.out.println(x); //3Select 1 option(s): It will print 2.5 It will print 2.0 It will print OptionalDouble[2.0] It will print OptionalDouble[3.0] It will print 2.0 if line at //2 is replaced with double x = is1.average(); It will print 2.5 if line at //2 is replaced with double x = is1.average();29. Question: Given :PERSON table in the database with the following data:ID(int) NAME(varchar) TAXID(varchar)--------------------1 Ally 1112 Bob 222and the following code: Connection c = ds.getConnection(); //assume that ds refers to a DataSource Statement stmt = c.createStatement(); String qr = "select * from PERSON"; try(ResultSet rs = stmt.executeQuery(qr); PreparedStatement ps1 = c.prepareStatement("update PERSON set taxid = 'NNNN' where id=?"); ) { while(rs.next()){ int id = rs.getInt(1); ps1.setInt(1, id); ps1.executeUpdate(); //1 System.out.println("Updated "+rs.getString(3)); //2 } }Identify correct statements.Select 2 option(s): It will execute one query on the database. It will execute two queries on the database. It will execute three queries on the database. It will throw an exception at //1 It will print: Updated NNNN Updated NNNN It will print: Updated 111 Updated 22230. Question: What will be the result of attempting to compile and run the following program?class TestClass{ public static void main(String args[]){ int i = 0;loop : // 1{System.out.println("Loop Lable line");try{ for ( ; true ; i++ ){if( i >5) break loop;// 2 }}catch(Exception e){System.out.println("Exception in loop.");}finally{System.out.println("In Finally"); // 3}}}}Select 1 option(s): Compilation error at line 1 as this is an invalid syntax for defining a label. Compilation error at line 2 as 'loop' is not visible here. No compilation error and line 3 will be executed. No compilation error and line 3 will NOT be executed. Only the line with the label loop will be printed.31. Question: Given the class// Filename: Test.java public class Test{public static void main(String args[]){ for(int i = 0; i< args.length; i++){System.out.print(" "+args[i]);} }} Now consider the following 3 options for running the program:a: java Testb: java Test param1 c: java Test param1 param2 Which of the following statements are true?Select 2 option(s): The program will throw java.lang.ArrayIndexOutOfBoundsException on option a. The program will throw java.lang.NullPointerException on option a. The program will print Test param1 on option b. It will print param1 param2 on option c. It will not print anything on option a.32. Question: What will be printed when the following code is compiled and run? package trywithresources;import java.io.IOException;public class Device{ String header = null; public void open(){ header = "OPENED"; System.out.println("Device Opened"); } public String read() throws IOException{ throw new IOException("Unknown"); } public void writeHeader(String str) throws IOException{ System.out.println("Writing : "+str); header = str; } public void close(){ header = null; System.out.println("Device closed"); } public static void testDevice(){ try(Device d = new Device()){ d.open(); d.read(); d.writeHeader("TEST"); d.close(); }catch(IOException e){ System.out.println("Got Exception"); } } public static void main(String[] args) { Device.testDevice(); } }Select 1 option(s): Device Opened Device closedGot Exception Device Opened Got ExceptionDevice closed Device Opened Got Exception The code will not compile.33. Question: What two changes can you do, independent of each other, to make the following code compile: //assume appropriate importsclass PortConnector { public PortConnector(int port) { if (Math.random() > 0.5) { //assume that random() returns a random value between 0.0 and 1.0) throw new IOException(); } throw new RuntimeException(); }}public class TestClass { public static void main(String[] args) { try { PortConnector pc = new PortConnector(10); } catch (RuntimeException re) { re.printStackTrace(); } }}Select 2 option(s): add throws IOException to the main method. add throws IOException to PortConnector constructor. add throws IOException to the main method as well as to PortConnector constructor. Change RuntimeException to java.io.IOException. add throws Exception to PortConnector constructor and change catch(RuntimeException re) to catch(Exception re) in the main method.34. Question: What will the following code print? List<String> names = Arrays.asList("Peter", "Paul", "Pascal");Optional<String> ops = names.stream() .parallel() .allMatch(name->name!=null) .filter(name->name.length()>6) .findAny();System.out.println(ops);Select 1 option(s): It may print any name out of the three in the list. It will print Optional.empty It will print Optional[Peter] It will not compile.35. Question: Which of the following statements will compile without any error? Select 4 option(s): System.out.println("a"+'b'+63); System.out.println("a"+63); System.out.println('b'+new Integer(63)); String s = 'b'+63+"a"; String s = 63 + new Integer(10);36. Question: What will the following program print?public class TestClass{static String str;public static void main(String[] args){System.out.println(str);}}Select 1 option(s): It will not compile. It will compile but throw an exception at runtime. It will print 'null' (without quotes). It will print nothing. None of the above.37. Question: Identify valid methods:Assume that Shape is a valid non-final class.Select 2 option(s): public List< Shape > m3(ArrayList< ? extends Shape > strList){List< ? extends Shape > list = new ArrayList<>();list.addAll(strList);return list;} public List< ? extends Shape > m4(List< ? extends Shape > strList){List< Shape > list = new ArrayList<>();list.add(new Shape()); list.addAll(strList); return list;} public void m5(ArrayList< ? extends Shape > strList){List< Shape > list = new ArrayList<>(); list.add(new Shape()); list.addAll(strList);} public void m6(ArrayList< Shape > strList){ List< ? extends Shape > list = new ArrayList<>();list.add(new Shape());strList.addAll(list); }38. Question: What will be the output when the following program is run?package exceptions; public class TestClass{public static void main(String[] args) { try{ hello();}catch(MyException me){System.out.println(me); }}static void hello() throws MyException{int[] dear = new int[7]; dear[0] = 747; foo();}static void foo() throws MyException{throw new MyException("Exception from foo"); }}class MyException extends Exception { public MyException(String msg){ super(msg);}} (Assume that line numbers printed in the messages given below are correct.)Select 1 option(s): Exception in thread "main"java.lang.ArrayIndexOutOfBoundsException: 10 at exceptions.TestClass.doTest(TestClass.java:24) at exceptions.TestClass.main(TestClass.java:14) Error in thread "main" java.lang.ArrayIndexOutOfBoundsException exceptions.MyException: Exception from foo exceptions.MyException: Exception from foo at exceptions.TestClass.foo(TestClass.java:29) at exceptions.TestClass.hello(TestClass.java:25) at exceptions.TestClass.main(TestClass.java:14)39. Question: What is the effect of compiling and running the code shown in exhibit?public class TestClass{public static void main (String args []){ var sum = 0; for (int i = 0, j = 10; sum > 20; ++i, --j) // 1{sum = sum+ i + j;}System.out.println("Sum = " + sum); }}Select 1 option(s): Compile time error at line 1. It will print Sum = 0 It will print Sum = 20 Runtime error. None of the above.40. Question: What will the following program print?public class TestClass{ static boolean b; static int[] ia = new int[1];static char ch; static boolean[] ba = new boolean[1]; public static void main(String args[]) throws Exception{ var x = false; if( b ){x = ( ch == ia[ch]); }else x = ( ba[ch] = b );System.out.println(x+" "+ba[ch]);}}Select 1 option(s): true true true false false true false false It will not compile.41. Question: Given that a class named mywids.Widget is part of a module named mod.wids packaged in mywidgets.jar, which of the following commands can be used to execute this class?(Assume that the jar file is located in the current directory and the jar file does not have any entry in its manifest.)Select 1 option(s): java --module-path mywidgets.jar --module mywids.Widget java --module-path mywidgets.jar --module mod.wids/mywids.Widget java --module-path mywidgets.jar --module mod.wids --main-class mywids.Widget java --module-path mywidgets.jar --module mod.wids mywids.Widget42. Question: What will be the output of the following lines ? System.out.println("" +5 + 6); //1System.out.println(5 + "" +6); // 2System.out.println(5 + 6 +""); // 3System.out.println(5 + 6); // 4Select 1 option(s): 56 561111 11 561111 56 565611 56 56 56 56 56 5611 5643. Question: Given:interface Carnivore{ default int calories(List<String> food){ return food.size()*100; } int eat(List<String> foods);}class Tiger implements Carnivore{ public int eat(List<String> foods){ System.out.println("Eating "+foods); return foods.size()*200; }}public class TestClass { public static int size(List<String> names){ return names.size()*2; } public static void process(List<String> names, Carnivore c){ c.eat(names); } public static void main(String[] args) { List<String> fnames = Arrays.asList("a", "b", "c"); Tiger t = new Tiger(); INSERT CODE HERE }}Which of the following options can be inserted independent of each other in the code above without any compilation error?Select 3 option(s): process(fnames, t::eat); process(fnames, t::calories); process(fnames, TestClass::size); process(fnames, Carnivore::calories); process(fnames, Tiger::eat);44. Question: Identify valid for loop constructs:Select 3 option(s): for(;Math.random()<0.5;){ System.out.println("true");} for(;;Math.random()<0.5){ System.out.println("true"); } for(;;Math.random()){System.out.println("true"); } for(;;){ Math.random()<.05? break : continue; } for(;;){ if(Math.random()<.05) break; }45. Question: Given:class A{ public List<? super Integer> getList(){ //valid code };}class B extends A{ @Override *INSERT CODE HERE* //valid code };}What can be inserted in the above code?Select 3 option(s): public List< ? extends Integer > getList(){ public List< ? super Number > getList(){ public List< ? extends Number > getList(){ public ArrayList< ? extends Integer > getList(){ public ArrayList< Number > getList(){ public ArrayList< Integer > getList(){46. Question: Given the following classes and declarations, which of these statements about //1 and //2 are true?class A{ private int i = 10; public void f(){} public void g(){} }class B extends A{ public int i = 20;public void g(){}}public class C{A a = new A();//1A b = new B();//2 }Select 1 option(s): System.out.println(b.i); will print 10. The statement b.f( ); will cause compile time error. System.out.println(b.i); will print 20 All of the above are correct. None of the above statements is correct.47. Question: Given:class Book{ private String title; private double price; public Book(String title, double price){ this.title = title; this.price = price; } //getters/setters not shown}What will the following code print?List<Book> books = Arrays.asList(new Book("Thinking in Java", 30.0), new Book("Java in 24 hrs", 20.0), new Book("Java Recipies", 10.0));double averagePrice = books.stream().filter(b->b.getPrice()>10) .mapToDouble(b->b.getPrice()) .average().getAsDouble();System.out.println(averagePrice);Select 1 option(s): It will not compile. It will throw an exception at runtime. 0.0 25.0 10.048. Question: Given:var data = new ArrayList<>();data.add("A");data.add(100); //1data.add("C");data.set(0, 200); //2data.remove(2); //3data.set(2, 101L);//4System.out.println(data);What will be the output?Select 1 option(s): It will not compile. Exception at run time on line marked //1. Exception at run time on line marked //2. Exception at run time on line marked //3. Exception at run time on line marked //4. [200, 100, 101]49. Question: You have created a module named mycompany.smartschool packaged in smartschool.jar. This module uses a third party non-modular java library packaged as utils.jar.How will you execute your module's main class named mycompany.smartschool.Main?(Assume that the jar files are located in the current directory.)Select 1 option(s): java --module-path smartschool.jar;utils.jar --module mycompany.smartschool/mycompany.smartschool.Main java -classpath utils.jar --module-path smartschool.jar --module mycompany.smartschool/mycompany.smartschool.Main java -cp utils.jar;smartschool.jar --module mycompany.smartschool/mycompany.smartschool.Main java -classpath utils.jar --module-jar smartschool.jar -main-class mycompany.smartschool/mycompany.smartschool.Main50. Question: Consider these two interfaces:interface I1{ void m1() throws java.io.IOException;}interface I2{ void m1() throws java.sql.SQLException;}What methods have to be implemented by a class that says it implements I1 and I2 ?Select 1 option(s): Both, public void m1() throws SQLException; and public void m1() throws IOException; public void m1() throws Exception The class cannot implement both the interfaces simultaneously as they have conflicting methods. public void m1() throws SQLException, IOException; None of the above.51. Question: What will the following code print when compiled and run: public class TestClass { public static void main(String[] args){ while(var k = 5; k<7){ System.out.println(k++); } }}Select 1 option(s): 56 567 It will keep printing 5. It will not compile. It will throw an exception at run time.52. Question: Given:class TestClass{ public static void main(String[] args) throws Exception { List<Integer> list = new CopyOnWriteArrayList<>(); ExecutorService es = Executors.newFixedThreadPool(5); CyclicBarrier cb = new CyclicBarrier(2, ()->System.out.print("All Done")); IntStream.range(0, 5).forEach(n->es.execute( ()->{ try{ list.add(n); cb.await(); }catch(InterruptedException|BrokenBarrierException e){ System.out.println("Exception"); } } )); es.shutdown(); }}What will the above program print?Select 2 option(s): It will print "All Done" once. It will print "All Done" twice. It will never print "All Done". It will print "All Done" once and end. It may print "All Done" once or twice. The program will not end. The program will end.53. Question: NOTE: Although CallableStatement is not mentioned explicitly in the exam objectives, some candidates has reported getting a question on it.What should be inserted in the following code so that it works as expected?String token = "xyz";String output = null;String processedValueCall = "{call reconciler(?,?)}";CallableStatement callableStatement = dbConnection.prepareCall(processedValueCall);*INSERT CODE HERE*callableStatement.executeUpdate();String value = callableStatement.getString(2);Assume that the token variable is the first parameter to be passed.Select 1 option(s): callableStatement.registerInParameter(1, java.sql.Types.VARCHAR); callableStatement.setString(1, token); callableStatement.registerOutParameter(2, java.sql.Types.VARCHAR); callableStatement.setString(2, output); callableStatement.setString(1, token);callableStatement.setString(2, java.sql.Types.VARCHAR); callableStatement.setString(1, token);callableStatement.registerOutParameter(2, java.sql.Types.VARCHAR); callableStatement.setString(1, token);callableStatement.registerOutParameter(2, output);54. Question: Which of the following is illegal ? Select 1 option(s): char c = 320; float f = 320; double d = 320; byte b = 320; float f = 22.0f/7.0f; None of the above is illegal.55. Question: Complete the following code by filling the two blanks -class XXX{ public void m() throws Exception{ throw new Exception(); }}class YYY extends XXX{ public void m(){ } public static void main(String[] args) { ________ obj = new ______(); obj.m(); }}Select 1 option(s): XXX XXX XXX YYY YYY XXX YYY YYY56. Question: Given://using title, price constructor to create Book instancesvar books = List.of(new Book("The Outsider", 2.99), new Book("Where the Crawdads Sing", 4.99 ), new Book("Elevation", 2.99), new Book("Coffin from Hong Kong", 1.99) );Stream<Book> bkStrm = books.stream();//double total = bkStrm.map(b->b.getPrice()).reduce(0.0, (a, b)->{ return a+b;}); //1Assuming appropriate constructor and methods, which of the following options are equivalent to the statement at //1 of the above code?Select 1 option(s): DoubleOperator myop = (a, b)->a+b;double total = bkStrm.map(b->b.getPrice()).reduce(0.0, myop); double total = bkStrm.map(b->b.getPrice()).reduce((a, b)->{ return a+b;}).ifPresent(p->p.doubleValue()); DoubleBinaryOperator dbo = (a, b)->a+b; double total = bkStrm.mapToDouble(b->b.getPrice()).reduce(0.0, dbo); BinaryOperator< Double > bo = (a, b)->a+b; double total = bkStrm.mapToDouble(b->b.getPrice()).reduce(0.0, bo); DoubleBinaryOperator dbo = (a, b)->a+b;double total = bkStrm.mapToDouble(b->b.getPrice()).reduce(dbo).get();57. Question: Given the following code:class TestClass{ public static void main(String args[]){ java.sql.Timestamp ts = new java.sql.Timestamp(1); java.awt.Label lb = new java.awt.Label("Time is "+ts); System.out.println(lb); }}and the following commands:javac TestClass.javajdeps -summary TestClass.javaWhat will be the output?Select 1 option(s): TestClass.class -> java.desktop TestClass.class -> java.sqlTestClass.class -> java.util TestClass.class -> java.base TestClass.class -> java.base TestClass.class -> java.se TestClass.class -> java.baseTestClass.class -> java.desktop TestClass.class -> java.sql TestClass.class -> java.base TestClass.class -> java.sqlTestClass.class -> java.utilTestClass.class -> java.desktop Compilation will be successful but the jdeps command will generate an error.Time is Up!