Welcome to your Test - 13 Code - 819 Name Email Phone 1. Question: Given:public class ItemProcessor implements Runnable{ //LINE 1 CyclicBarrier cb; public ItemProcessor(CyclicBarrier cb){ this.cb = cb; } public void run(){ System.out.println("processed"); try { cb.await(); } catch (Exception ex) { ex.printStackTrace(); } }}public class Merger implements Runnable{ //LINE 2 public void run(){ System.out.println("Value Merged"); }}What should be inserted in the following code such that run method of Merger will be executed only after the thread started at 4 and the main thread have both invoked await? public static void main(String[] args) throws Exception{ var m = new Merger(); //LINE 3 var ip = new ItemProcessor(cb); ip.start(); //LINE 4 cb.await(); }Select 1 option(s): Make ItemProcessor extend Thread instead of implementing Runnable and add CyclicBarrier cb = new CyclicBarrier(1, m); to //LINE 3 Make ItemProcessor extend Thread instead of implementing Runnable and add CyclicBarrier cb = new CyclicBarrier(2, m); to //LINE 3 Make Merger extend Thread instead of implementing Runnable and add CyclicBarrier cb = new CyclicBarrier(1, m); to //LINE 3 Make Merger extend Thread instead of implementing Runnable and add CyclicBarrier cb = new CyclicBarrier(2, m); to //LINE 3 Just add CyclicBarrier cb = new CyclicBarrier(1, m); to //LINE 3 Just add CyclicBarrier cb = new CyclicBarrier(2, m); to //LINE 32. Question: Consider the code shown below:public class TestClass{ public static int switchTest(int k){ var j = 1; switch(k){ case 1: j++; case 2: j++; case 3: j++; case 4: j++; case 5: j++; default : j++; } return j + k; } public static void main(String[] args){ System.out.println( switchTest(4) ); }}What will it print when compiled and run?Select 1 option(s): 5 6 7 8 9 It will not compile.3. Question: What will the following code print when compiled and run? import java.util.*;public class TestClass { public static void main(String[] args) throws Exception { List list = new ArrayList(); list.add("val1"); //1 list.add(2, "val2"); //2 list.add(1, "val3"); //3 System.out.println(list); }}Select 1 option(s): It will not compile. It will throw an exception at run time because of line //1 It will throw an exception at run time because of line //2 It will throw an exception at run time because of line //3 null4. Question: Given the following class, which statements can be inserted at line 1 without causing the code to fail compilation?public class TestClass{ int a; int b = 0; static int c;public void m(){ int d; int e = 0; // Line 1}}Select 4 option(s): a++; b++; c++; d++; e++;5. Question: Which of the following are correct ways to initialize the static variables MAX and CLASS_GUID ?class Widget{ static int MAX; //1 static final String CLASS_GUID; // 2Widget(){//3}Widget(int k){ //4}}Select 2 option(s): Modify lines //1 and //2 as : static int MAX = 111; static final String CLASS_GUID = "XYZ123"; Add the following line just after //2 : static { MAX = 111; CLASS_GUID = "XYZ123"; } Add the following line just before //1 : { MAX = 111; CLASS_GUID = "XYZ123"; } Add the following line at //3 as well as //4 : MAX = 111; CLASS_GUID = "XYZ123"; Only option 3 is valid.6. Question: What can be added to the following Person class so that it is properly encapsulated and the code prints 29? class Person{ //Insert code here}public class Employee extends Person{ public static void main(String[] args) { Employee e = new Employee(); e.setAge(29); System.out.println(e.getAge()); }}Select 2 option(s): private int age;public int getAge() {return age;}public void setAge(int age) {this.age = age; } protected int age;public int getAge(){return age; }public void setAge(int age) {this.age = age; } int age; public int getAge() {return age;}public void setAge(int age) {this.age = age; } private int age; private int getAge() { return age; }private void setAge(int age) {this.age = age;} private int age; public int getAge() {return age; }protected void setAge(int age) {this.age = age; }7. Question: Given that a method named Double getPrice(String id) exists and may potentially return null, about which of the following options can you be certain that a run time exception will not be thrown?Select 2 option(s): Optional< Double > price = Optional.of(getPrice("1111")); Optional< Double > price = Optional.ofNullable(getPrice("1111"));Double x = price.orElse(getPrice("2222")); Optional< Double > price = Optional.ofNullable(getPrice("1111")); Double y = price.orElseGet(()->getPrice("333")); Optional< Double > price = Optional.of(getPrice("1111"), 10.0); Optional< Double > price = Optional.of(getPrice("1111"));Double z = price.orElseThrow(()->new RuntimeException("Bad Code"));8. Question: Given:class Square { private double side = 0; String color; public Square(double length){ this.side = length; } public double getSide() { return side; } public void setSide(double side) { this.side = side; } }public class TestClass { public static void main(String[] args) throws Exception { Square mysq = new Square(10); mysq.color = "red"; //set mysq's side to 20 }}Which of the following statements will set the side of Square object referred by mysq to 20?Select 1 option(s): mysq.side = 20; mysq = new Square(20); mysq.setSide(20); side = 20; Square.mysq.side = 20;9. Question: Given the following class definition:class A{ protected int i; A(int i) { this.i = i; }}//1 : Insert code hereWhich of the following would be a valid class that can be inserted at //1 ?Select 2 option(s): class B {} class B extends A {} class B extends A { B() { System.out.println("i = " + i); } } class B { B() {} }10. Question: Given:public class Student { private String name; private int marks; public Student(String name, int marks){ this.name = name; this.marks = marks; } public String toString(){ return name+":"+marks; } //getters and setters not shown}What can be inserted in the code below so that it will print:{20=[S1:20, S3:20], 30=[S3:30]}List<Student> ls = Arrays.asList(new Student("S1", 20), new Student("S3", 30), new Student("S3", 20) );//INSERT CODE HERESystem.out.println(grouping);Select 1 option(s): Map< Integer, List< Student > > grouping = ls.stream().collect( Collectors.groupingBy(Student::getMarks, Collectors.mapping(Student::getName, Collectors.toList())) ); Map< Integer, List< Student > > grouping = ls.stream().collect(Collectors.groupingBy( Student::getMarks,Student)); Map< Integer, List< Student > > grouping = ls.stream().collect( Collectors.groupingBy( Student::getMarks,new ArrayList()) ); Map< Integer, List< Student > > grouping = ls.stream().collect(Collectors.groupingBy(s ->s.getMarks()));11. Question: Note: jmod is not on the part 1 exam. However some candidates have seen it mentioned in one of the incorrect options. You may read about jmod if you have time.Which of the following options are supported by jmod?Select 4 option(s): create add delete list extract describe12. Question: Consider the following code appearing in the same file:class Data { int x = 0, y = 0;public Data(int x, int y){this.x = x; this.y = y;}}public class TestClass {public static void main(String[] args) throws Exception {Data d = new Data(1, 1);//add code here}} Which of the following options when applied individually will change the Data object currently referred to by the variable d to contain 2, 2 as values for its data fields?Select 2 option(s): Add the following two statements: d.x = 2; d.y = 2; Add the following statement:d = new Data(2, 2); Add the following two statements: d.x += 1; d.y += 1; Add the following statement: d = d + 1;13. Question: What will the code shown below print when run?class Wrapper{ int w = 10; }public class TestClass{ static Wrapper changeWrapper(Wrapper w){w = new Wrapper();w.w += 9;return w;}public static void main(String[] args){var w = new Wrapper(); w.w = 20;changeWrapper(w); w.w += 30; System.out.println(w.w);w = changeWrapper(w); System.out.println(w.w);}}Select 2 option(s): 9 19 30 20 29 5014. Question: What will the following program print when run? public class Operators{ public static int operators(){ int x1 = -4; int x2 = x1--; int x3 = ++x2; if(x2 > x3){ --x3; }else{ x1++; } return x1 + x2 + x3; } public static void main(String[] args) { System.out.println(operators()); }}Select 1 option(s): -9 -10 -11 -1215. Question: Given:public class ThreadSafety{ List sList = new ArrayList();public Student getStudent(){ var s = sList.remove(0);return s;} ...other irrelevant code } If two threads, T1 and T2, concurrently execute getStudent() method on the same ThreadSafety instance, which of the following are possible outcomes? (Assume that there are no nulls in the list.)Select 3 option(s): T1 gets a Student object and T2 gets IndexOutOfBoundsException. T1 and T2 get two different instances of Student objects. T1 gets a Student object and T2 gets null. T1 gets a Student object and T2 gets a ConcurrentModificationException. Both the threads get a reference to the same Student object.16. Question: Consider the following code:import java.util.*;import java.text.*;public class TestClass{ public static void main(String[] args) throws Exception { double amount = 53000.35; Locale jp = new Locale("jp", "JP"); //1 create formatter here. System.out.println( formatter.format(amount) ); }}How will you create formatter using a factory at //1 so that the output is in Japanese Currency format?Select 2 option(s): NumberFormat formatter = NumberFormat.getCurrencyFormatter(jp); NumberFormat formatter = new DecimalFormat(jp); Format formatter = NumberFormat.getCurrencyInstance(jp); NumberFormat formatter = DecimalFormat.getCurrencyInstance(jp); NumberFormat formatter = NumberFormat.getInstance(jp); NumberFormat formatter = new DecimalFormat("#.00");17. Question: A programmer has written the following code for Address class. The programmer intends this class to be immutable.public class Address { private String hNo; private String street; private String zip; public Address(String h, String s, String z){ this.hNo = h; this.street = s; this.zip = z; } //only getters for three fields. No setters.}Which of the following actions implement the Java SE Secure guidelines?Select 2 option(s): Make the class final. Make the constructor private and provide a static factory method to return Address instances. Make the fields final. Make the getter methods synchronized.18. Question: What will the following code print? List<Integer> str = Arrays.asList(1,2, 3, 4 );str.stream().filter(x->{ System.out.print(x+" "); return x>2;});Select 1 option(s): 1 2 3 4 1 2 3 4 4 4 It will not print anything.19. Question: What will the following command show? jdeps --list-deps moduleA.jarSelect 2 option(s): It will list all the modules on which moduleA depends. It will list all the packages of all the modules on which moduleA depends. It will list all the standard JDK modules on which moduleA depends. It checks whether moduleA.jar contains all the required modules and prints the ones not present. It will show an error if moduleA requires any other application module.20. Question: Given:@Target(value={TYPE_USE,TYPE_PARAMETER})public @interface Interned{}andpublic class Account{}Identify correct usages.Select 2 option(s): var str = "Hello"+ (@Interned) "World"; var str = "Hello"+ (@Interned "World"); @Interned Account acct = new Account(); Account acct = new @Interned Account(); Account acct = @Interned new Account();21. Question: Given that the file test.txt is accessible and contains multiple lines, which of the following code fragments will correctly print all the lines from the file?Select 2 option(s): Stream< String > lines = Files.find(Paths.get("test.txt"));lines.forEach(System.out::println); BufferedReader bfr = new BufferedReader(new FileReader("test.txt"));System.out.println(bfr.readLines()); Stream< String > lines = Files.list(Paths.get("test.txt"));lines.forEach(x->System.out.println(x)); Stream< String > lines = Files.lines(Paths.get("test.txt"));lines.forEach(System.out::println); Stream< String > lines = Files.lines(Paths.get("test.txt"), Charset.defaultCharset());lines.forEach(s -> System.out.println(s));22. Question: What will the following code snippet print when compiled and run? byte starting = 3;short firstValue = 5;int secondValue = 7;int functionValue = (int) (starting/2 + firstValue/2 + (int) firstValue/3 ) + secondValue/2;System.out.println(functionValue);Select 1 option(s): 7 8 10 11 12 It will not compile.23. Question: Which of the following statements about deadlock is correct? Select 1 option(s): A deadlock occurs when threads become so busy in responding to each other that they are unable to perform any real work. Deadlock occurs when a thread is frequently unable to get access to a resource because the resource is hogged by other threads most of the time. Thread 1 and 2 are said to be deadlocked when Thread 1 is blocked waiting for Thread 2 to release a resource, while Thread 2 is blocked waiting for Thread 1 to release another resource. A deadlock is caused by starvation, which in turn is caused by a live lock. A deadlock is caused when, in a multi core CPU system, one of the cores get offline or corrupt.24. Question: Given:String INPUT_FILE = "c:\\temp\\src\\foo.bar\\module-info.java";Assuming the file exists, which of the following options will print the contents of the file?Select 2 option(s): Files.lines(INPUT_FILE).forEach(System.out::println); Stream< String > lines = Files.lines(Paths.get(INPUT_FILE));lines.forEach(System.out::println); Stream< String > lines = Files.readAllLines(Paths.get(INPUT_FILE));lines.forEach(System.out::println); List< String > lines = Files.readAllLines(Paths.get(INPUT_FILE));lines.forEach(System.out::println); List< String > lines = Files.lines(Paths.get(INPUT_FILE)); lines.forEach(System.out::println); String[] stra = Files.readLines(Paths.get(INPUT_FILE)); for(String s: stra) System.out.println(s);25. Question: Consider the following code:interface Bar{ void bar();}abstract class FooBase{ public static void bar(){ System.out.println("In static bar"); } }public class Foo extends FooBase implements Bar {}What can be done to the above code so that it will compile without any error?Select 1 option(s): Add this method in class Foo - public void bar(){ }; Make the bar method in Bar interface default like this -default void bar() { } Either of the two approaches presented above will work. Neither of the two approaches presented above will work. Nothing needs to be done. It will compile as it is.26. Question: Identify correct statement(s) about the following code: var value = 1,000,000; //1 switch(value){ case 1_000_000 : System.out.println("A million 1"); //2 break; case 1000000 : System.out.println("A million 2"); //3 break; }Select 1 option(s): It will print A million 1 when compiled and run. It will print A million 2 when compiled and run. Compilation fails only at line //1 Compilation fails only at line //2 Compilation fails only at line //3 Compilation fails at line //1 and //327. Question: Given:import java.io.FileNotFoundException;import java.io.IOException;public class Scrap { public static void main(String[] args) { try{ if(args.length == 0) m2(); else m3(); } INSERT CODE HERE } public static void m2() throws IOException { throw new FileNotFoundException(); } public static void m3() throws IndexOutOfBoundsException{ throw new IndexOutOfBoundsException(); }}Assuming that the above code is always invoked with at least one argument, what can be inserted in the above code to make it compile?Select 2 option(s): catch(IOException e){ } catch(FileNotFoundException fe){ } catch(IOException|IndexOutOfBoundsException e){ } catch(FileNotFoundException|IndexOutOfBoundsException e){ } catch(RuntimeException re){ }28. Question: You are writing a piece of code that determines tax rate on a given grossIncome. The tax rate is to be computed as follows - If grossIncome is less than or equals to 18000, taxRate is 0. If grossIncome is more than 18000 but less than or equal to 36000, taxRate is 10% If grossIncome is more than 36000, taxRate is 20%.Which of following code fragments do it correctly?Select 3 option(s): double taxRate = grossIncome<=18000 ? 0 : (grossIncome<=36000) ? .1 : .2; double taxRate = .2; taxRate = grossIncome<=18000?0:.1;taxRate = grossIncome<=36000?.1:.2; double taxRate = 0; if(grossIncome>36000) taxRate = .20;if(grossIncome>18000 && grossIncome<=36000) taxRate = .10; double taxRate = .2;if(grossIncome>36000) { taxRate = .2; }else taxRate = 0;if(grossIncome>18000 ) {taxRate = .1; } double taxRate = 0;taxRate = grossIncome>18000?grossIncome<=36000?.1:.2:0;29. Question: Consider the following method...public static void ifTest(boolean flag){ if (flag) //1 if (flag) //2if (flag) //3System.out.println("False True");else //4 System.out.println("True False");else //5System.out.println("True True");else //6 System.out.println("False False");} Which of the following statements are correct ?Select 2 option(s): If run with an argument of 'false', it will print 'False False' If run with an argument of 'false', it will print 'True True' If run with an argument of 'true', it will print 'True False' It will never print 'True True' It will not compile.30. Question: Which is the earliest line in the following code after which the object created on line // 1 can be garbage collected, assuming no compiler optimizations are done?public class NewClass{ private Object o; void doSomething(Object s){ o = s; }public static void main(String args[]){Object obj = new Object(); // 1NewClass tc = new NewClass(); //2 tc.doSomething(obj); //3 obj = new Object(); //4obj = null; //5 tc.doSomething(obj); //6 }}Select 1 option(s): Line 1 Line 2 Line 3 Line 4 Line 5 Line 631. Question: Given:public class TestClass{ static int someMethod(){ return 100; } static class MyWorker{ Runnable r; public MyWorker(Runnable r){ this.r = r; } } public static void main(String[] args) { //INSERT CODE HERE MyWorker w = new MyWorker(r); }}What can be inserted in the above code?Select 3 option(s): Runnable r = ()->System.out.println("Hello"); Runnable r = { System.out.println("Hello");} Runnable r = () -> System.out::println(); Runnable r = (a)->System.out.println(a); Runnable r = -> System.out.println(); Runnable r = ()-> { someMethod(); }; Runnable r = ()-> someMethod();32. Question: Consider the following code:class Super { static String ID = "QBANK"; }class Sub extends Super{ static { System.out.print("In Sub"); }}public class Test{public static void main(String[] args){System.out.println(Sub.ID);}} What will be the output when class Test is run?Select 1 option(s): It will print In Sub and QBANK. It will print QBANK. Depends on the implementation of JVM. It will not even compile. None of the above.33. Question: Given:class M { static Object obj = null; public M(String val){ obj = val; }}class N{ private M m = new M("hello"); public static void main(String[] args){ N n = new N(); n = null; System.gc(); System.out.println(M.obj); }}Assuming that System.gc() does its job, what will be printed?Select 1 option(s): null It will throw a NullPointerException at run time. hello It will thrown an IllegalAccessException at run time. It will not compile.34. Question: Given:class MyProcessor{ public void process(){ System.out.println("Processing "); }}public class TestClass { public static void main(String[] args) { process(()->new MyProcessor()); //1 REPLACE THIS LINE OF CODE } public static void process(Supplier<MyProcessor> s){ s.get().process(); }}Which of the following options correctly replaces the line marked //1 with code that uses method reference?Select 1 option(s): TestClass.process(MyProcessor::new); TestClass.process(new::MyProcessor); TestClass.process(MyProcessor::new()); TestClass.process(new::MyProcessor()); TestClass.process(MyProcessor()::new);35. Question: Consider the following class :public class Test{ public static void main(String[] args){ if (args[0].equals("open")) if (args[1].equals("someone")) System.out.println("Hello!"); else System.out.println("Go away "+ args[1]); }}Which of the following statements are true if the above program is run with the command line :Select 1 option(s): It will throw ArrayIndexOutOfBoundsException at runtime. It will end without exceptions and will print nothing. It will print Go away It will print Go away and then will throw ArrayIndexOutOfBoundsException. None of the above.36. Question: Given:String qr = INSERT CODE HEREtry(PreparedStatement ps = connection.prepareStatement(qr);){...}What can be inserted in the above code?Select 1 option(s): "insert into USERINFO values( ?, ?, ?, ?)"; (Assuming USERINFO table with four columns exists.) "update USERINFO set NAME=? where ID=?";(Assuming USERINFO table with NAME and ID columns exists.) "delete from USERINFO where ID=2"; (Assuming USERINFO table with ID column exists.) All of the above.37. Question: Given the following code fragment, which of the following lines would be a part of the output?outer: for ( var i = 0 ; i<3 ; i++ ){for ( var j = 0 ; j<2 ; j++ ){if ( i == j ){ continue outer; }System.out.println( "i=" + i + " , j=" + j );}}Select 2 option(s): i = 1, j = 0 i = 0, j = 1 i = 1, j = 2 i = 2, j = 1 i = 2, j = 238. Question: Considering the following program, which of the options are true?public class FinallyTest{ public static void main(String args[]){ try{ if (args.length == 0) return; else throw new Exception("Some Exception"); } catch(Exception e){ System.out.println("Exception in Main"); } finally{ System.out.println("The end"); } }}Select 2 option(s): If run with no arguments, the program will only print 'The end'. If run with one argument, the program will only print 'The end'. If run with one argument, the program will print 'Exception in Main' and 'The end'. If run with one argument, the program will only print 'Exception in Main'. If run with no arguments, the program will not print anything. If run with no arguments, the program will generate a stack trace on the console.39. Question: Given:import java.util.Iterator;import java.util.Map.Entry;import java.util.concurrent.ConcurrentHashMap;public class Cache { static ConcurrentHashMap<String, Object> chm = new ConcurrentHashMap<String, Object>(); public static void main(String[] args) { chm.put("a", "aaa"); chm.put("b", "bbb"); chm.put("c", "ccc"); new Thread(){ public void run(){ Iterator<Entry<String, Object>> it = Cache.chm.entrySet().iterator(); while(it.hasNext()){ Entry<String, Object> en = it.next(); if(en.getKey().equals("a") || en.getKey().equals("b")){ it.remove(); } } } }.start(); new Thread(){ public void run(){ Iterator<Entry<String, Object>> it = Cache.chm.entrySet().iterator(); while(it.hasNext()){ Entry<String, Object> en = it.next(); System.out.print(en.getKey()+", "); } } }.start(); }}Which of the following are possible outputs when the above program is run?Select 1 option(s): It may print any combination of the keys. It may print any combination except: c, It may print any combination except: a, or b, or a, b, or b, a It may print any combination except: b, c, It may print any combination except: a, b,40. Question: What will the following code print? import java.util.Optional;public class NewClass { public static Optional<String> getGrade(int marks){ Optional<String> grade = Optional.empty(); if(marks>50){ grade = Optional.of("PASS"); } else { grade.of("FAIL"); } return grade; } public static void main(String[] args) { Optional<String> grade1 = getGrade(50); Optional<String> grade2 = getGrade(55); System.out.println(grade1.orElse("UNKNOWN")); if(grade2.isPresent()){ grade2.ifPresent(x->System.out.println(x)); }else{ System.out.println(grade2.orElse("Empty")); } }}Select 1 option(s): UNKNOWN PASS Optional[UNKNOWN] PASS Optional[UNKNOWN]Optional[PASS] FAIL PASS Optional[FAIL] OPTIONAL[PASS]41. Question: Which statements about the following code are correct? interface House{ public default String getAddress(){ return "101 Main Str"; }}interface Office { public default String getAddress(){ return "101 Smart Str"; }}class HomeOffice implements House, Office{ public String getAddress(){ return "R No 1, Home"; }}public class TestClass { public static void main(String[] args) { House h = new HomeOffice(); //1 System.out.println(h.getAddress()); //2 }}Select 1 option(s): Code for class HomeOffice will cause compilation to fail. Line at //1 will cause compilation to fail. Line at //2 will cause compilation to fail. The code will compile successfully if the getAddress method is removed from class HomeOffice. It will compile fine and print R No 1, Home when run.42. Question: Consider the following code:class Base{ private float f = 1.0f;void setF(float f1){ this.f = f1; }}class Base2 extends Base{ private float f = 2.0f; //1} Which of the following options is/are valid example(s) of overriding?Select 2 option(s): protected void setF(float f1){ this.f = 2*f1; } public void setF(double f1){ this.f = (float) 2*f1; } public void setF(float f1){ this.f = 2*f1; } private void setF(float f1){ this.f = 2*f1; } float setF(float f1){ this.f = 2*f1; return f;}43. Question: Which of the following commands can be used to identify class and module dependencies of a class named test.A of module named moduleA without executing it? Assume that all module files are stored in out directory.Note: Although identifying module dependency is not explicitly mentioned in the exam objectives, we have seen questions on the exam that require you to know about the tool that is used to identify module dependencies.Select 1 option(s): 44. Question: You are trying to compile your module named mycompany.finance. You have put all the source files for your module in src directory. However, your module requires a mycompany.utils module, which is delivered by another team of your company in the form of mycompany.utils.jar file. You have kept this jar in libs directory.Which of the following commands can be used to compile your module?Select 1 option(s): javac --module-source-path src -classpath libs/mycompany.utils.jar --module src javac --module-source-path src -p libs/mycompany.utils.jar -d out -m mycompany.finance javac -source-path src -classpath libs -d out --module mycompany.finance javac --module-source-path src -m libs -d out -s mycompany.finance javac -s src -p libs -d out -m mycompany.finance45. Question: What will be the result when you try to compile and run the following code? public class TestClass{ public static void main(String args[] ) { var out = new Outer(); System.out.println(out.getInner().getOi()); }}class Outer{ private int oi = 20; class Inner { int getOi() { return oi; } } Inner getInner() { return new Inner() ; }}Select 1 option(s): The code will fail to compile as the inner class Inner is not defined properly. The code will fail to compile because the reference of an inner class cannot be passed outside the outer class. The code will fail to compile, since the method getOi( ) is not visible from the main( ) method in the TestClass. The code will compile without error and will print 20 when run. None of the above.46. Question: What will be the output when the following program is run?public class TestClass{char c;public void m1(){ char[ ] cA = { 'a' , 'b'};m2(c, cA); System.out.println( ( (int)c) + "," + cA[1] ); }public void m2(char c, char[ ] cA){c = 'b'; cA[1] = cA[0] = 'm';}public static void main(String args[]){ new TestClass().m1(); }}Select 1 option(s): Compile time error. ,m 0,m b,b b,m47. Question: What will be the output of the following program? class TestClass{ public static void main(String[] args) throws Exception{ try{ amethod(); System.out.println("try "); } catch(Exception e){ System.out.print("catch "); } finally { System.out.print("finally "); } System.out.print("out "); } public static void amethod(){ }}Select 1 option(s): try finally try finally out try out catch finally out It will not compile because amethod() does not throw any exception.48. Question: Given:String sentence = "Life is a box of chocolates, Forrest. You never know what you're gonna get."; //1Optional<String> theword = Stream.of(sentence.split("[ ,.]")).anyMatch(w->w.startsWith("g")); //2System.out.println(theword.get()); //3Which of the following statements are correct?Select 1 option(s): It may print either gonna or get. It will print gonna. It may print either gonna or get if lines //2 and //3 are changed to: String theword = Stream.of(sentence.split("[ ,.]")).anyMatch(w->w.startsWith("g")); //2 System.out.println(theword.get);//3 It may print either gonna or get if lines //2 and //3 are changed to: Optional< String > theword = Stream.of(sentence.split("[ ,.]")).parallel().anyMatch(w->w.startsWith("g")); //2 System.out.println(theword.get()); //3 It will fail to compile.49. Question: Consider the following method:public void setSQLMode(Connection c, String mode) throws Exception{ Statement stmt = c.createStatement(); String qr = "SET SESSION sql_mode = '"+mode+"';"; stmt.execute(qr);}Identify the correct statement about the above code.Select 1 option(s): mode should enquoted like this:String qr = "SET SESSION sql_mode = "+stmt.enquoteIdentifier(mode, false)+";"; because enquoting values provided by the calling code prevents SQL injection attacks. There is no need to enquote mode because identifiers need not be enquoted. There is no need to enquote mode because the calling code would have enquoted it already. Enquoting mode would make no difference because it is functionally equivalent to the current statement. mode should be enquoted because all user input should be enquoted.50. Question: What will the following code print? Path p1 = Paths.get("c:\\temp\\test.txt"); Path p2 = Paths.get("c:\\temp\\report.pdf"); System.out.println(p1.resolve(p2));Select 1 option(s): 51. Question: Given:enum Coffee{ ESPRESSO("Very Strong"), MOCHA("Bold"), LATTE("Mild"); public String strength; Coffee(String strength) { this.strength = strength; } public String toString(){ return strength; }}Which of the given code snippets will produce the following output:ESPRESSO:Very Strong, MOCHA:Bold, LATTE:Mild,Select 1 option(s): List.of(Coffee.values()).stream().forEach(e->{System.out.print(e+":"+e.value()+", ");}); List.of(Coffee.values()).stream().forEach(e->{System.out.print(e.name()+":"+e+", ");}); Coffee.values().forEach(e->{System.out.print(e.name()+":"+e+", ");}); List.of(Coffee.values()).forEach(e->{System.out.print(e+":"+e.name()+", ");}); Coffee.forEach(e->{System.out.print(e.strength+":"+e.name()+", ");});52. Question: Which of the following lambda expressions can be used to implement a Function<Integer, String> ? Select 1 option(s): (a)-> 2*a (a, s)-> a+" "+s (s) ->"hello "+s+"!" (a, s, r)-> a+" "+s (a)-> System.out.println("done")53. Question: Given the following code that appears inside a method: var values = new ArrayList<String>(); //INSERT CODE HEREWhat can be inserted at the given location without causing any compilation error?Select 4 option(s): values.forEach(var k->System.out.print(k.length())); values.forEach( (var k)->System.out.print(k.length())); values.forEach( k -> System.out.print(k.length())); var k = values.get(0); values.add(k); for(var value : values){ } values.add(1);54. Question: Which of the changes given in options can be done (independent of each other) to let the following code compile and run without errors when its generateReport method is called? class SomeClass{ String s1 = "green mile"; // 0 public void generateReport( int n ){ String local; // 1 if( n > 0 ) local = "good"; //2 System.out.println( s1+" = " + local ); //3 }}Select 2 option(s): Replace String at //0 with var. Insert after line 2 : if(n <= 0) local = "bad"; Move line 1 and place it after line 0. change line 1 to : final String local = "rocky"; Insert after line 2 : else local = "bad"; The program already is without any errors.Time is Up!