Welcome to your Test - 8 Code - 819 Name Email Phone 1. Question: Consider the following code:public class TestOuter{ public void myOuterMethod() { // 1 } public class TestInner { } public static void main(String[] args) { var to = new TestOuter(); // 2 }}Which of the following options correctly instantiates a TestInner object?Select 2 option(s): new TestInner(); at //1 new TestInner(); at //2 new to.TestInner(); at //2 new TestOuter.TestInner(); at //2 new TestOuter().new TestInner(); at //12. Question: A modularized application has been packaged in graphs.jar file with module name as com.xcomp.graphs. The entry point of the application is a class named Main in package com.xcomp.graphs.Which two options can be used to execute this application?Select 2 option(s): java --module-path graphs.jar --module com.xcomp.graphs.Main java --module-path graphs.jar --module com.xcomp.graphs/com.xcomp.graphs.Main java -classpath graphs.jar --module com.xcomp.graphs/com.xcomp.graphs.Main java --module-path graphs.jar com.xcomp.graphs.Main java -classpath graphs.jar com.xcomp.graphs.Main java --module-path graphs.jar --main-class com.xcomp.graphs.Main3. Question: What will be the output of the following program ?class CorbaComponent{ String ior; CorbaComponent(){ startUp("IOR"); }void startUp(String s){ ior = s; }void print(){ System.out.println(ior); }}class OrderManager extends CorbaComponent{ OrderManager(){ }void startUp(String s){ ior = getIORFromURL(s); } String getIORFromURL(String s){ return "URL://"+s; } }public class Application{public static void main(String args[]){ start(new OrderManager()); } static void start(CorbaComponent cc){ cc.print(); } }Select 1 option(s): It will throw an exception at run time. It will print IOR It will print URL://IOR It will not compile. None of the above.4. Question: What will the following code print when run? import java.util.*;import java.text.*;public class TestClass{ public static void main(String[] args) { double amount = 123456.789; Locale fr = new Locale("fr", "FR"); NumberFormat formatter = NumberFormat.getInstance(fr); String s = formatter.format(amount) ; formatter = NumberFormat.getInstance(); Number amount2 = formatter.parse(s); System.out.println( amount + " " + amount2 ); }}Select 1 option(s): It will always print two equal numbers. It will always print two unequal numbers. It will not compile. It will throw an exception at runtime. None of these.5. Question: Given:public class UserCredential implements Serializable{ private String useridpwd; public UserCredential(String useridpwd){ this.useridpwd = useridpwd; }}Which options can be used to secure serialization of the objects of the above class?Note: This is a vague question because it is not clear exactly what is expected when it says "secure serialization of the objects". Does it mean the useridpwd must not be stored in the serialized data, does it mean UserCredential object must not be serialized, or does it mean the useridpwd field must not be tampered with or something else.We have seen similar question on the exam. You should go through Oracle's secure coding guideline article before answering this question: Select 4 option(s): Make useridpwd field transient. Add serialPersistentFields array field in the class. Implement only writeReplace method to replace the instance with a serial proxy and not readReplace. Implement only readResolve method to replace the instance with a serial proxy and not writeReplace. Implement writeObject and use ObjectOutputStream.putField selectively Do not implement the Externalizable interface6. Question: Given:public class SimpleLoop { public static void main(String[] args) { int i=0, j=10; var count = 0; while (i<j) { i++; j--; count++; } System.out.println(i+" "+j+" "+count); }}What is the result?Select 1 option(s): 6 4 5 6 5 5 6 5 6 6 4 6 5 5 57. Question: Which of the following are true regarding overloading of a method? Select 1 option(s): An overloading method must have a different parameter list and same return type as that of the overloaded method. If there is another method with the same name but with a different number of arguments in a class then that method can be called as overloaded. If there is another method with the same name and same number and type of arguments but with a different return type in a class then that method can be called as overloaded. An overloaded method means a method with the same name and same number and type of arguments exists in the super class and sub class.8. Question: Given:class Person{ private String name; private int age; public Person(String name, int age){ this.name = name; this.age = age; } //getters/setters not shown}What will the following code print?List<Person> friends = Arrays.asList(new Person("Bob", 31), new Person("Paul", 32), new Person("John", 33));double averageAge = friends.stream().filter(f->f.getAge()<30) .mapToInt(f->f.getAge()) .average().getAsDouble();System.out.println(averageAge);Select 1 option(s): It will not compile. It will throw an exception at runtime. 0.0 32.0 0 329. Question: Which of these are NOT legal declarations within a class? Select 1 option(s): static int sa ; final Object[ ] objArr = { null } ; abstract int t ; abstract void format( ) ; final static private double PI = 3.14159265358979323846 ;10. Question: Consider the following program:import java.io.FileReader;import java.io.FileWriter;public class ClosingTest { public static void main(String[] args) throws Exception { try(FileReader fr = new FileReader("c:\\temp\\license.txt"); FileWriter fw = new FileWriter("c:\\temp\\license2.txt") ) { int x = -1; while( (x = fr.read()) != -1){ fw.write(x); } } }}Identify the correct statements.Select 1 option(s): The FileWriter object will always be closed before the FileReader object. The order of the closure of the FileWriter and FileReader objects is platform dependent and should not be relied upon. The FileWriter object will not be closed if an exception is thrown while closing the FileReader object. This is not a fail safe approach to managing resources because in certain situations one or both of the resources may be left open after the end of the try block.11. Question: What will the following program print? class Test{ public static void main(String args[]){ var k = 9; var s = 5; switch(k){ default : if( k == 10) { s = s*2; } else{ s = s+4; break; } case 7 : s = s+3; } System.out.println(s); }}Select 1 option(s): 5 9 12 It will not compile.12. Question: The following code snippet will print 4.int i1 = 1, i2 = 2, i3 = 3;int i4 = i1 + (i2=i3 ); System.out.println(i4);Select 1 option(s): True False13. Question: Which of the following code snippet will print 10 random double values? Note: Although not mentioned in the exam objectives, we have seen questions that require knowledge about java.lang.Random class on the exam.Select 3 option(s): new Random().doubles(10).forEach(System.out::print); Random r = new Random(); DoubleStream rDoubles = r.generate().limit(10); rDoubles.forEach(System.out::print); Random r = new Random(); DoubleStream rDoubles = r.doubles().limit(10); rDoubles.forEach(System.out::print); Random r = new Random(); DoubleStream.generate(()->r.nextDouble()).limit(10).forEach(System.out::print); DoubleStream.generate(Random::nextDouble).limit(10).forEach(System.out::print);14. Question: What will the following code print when compiled and run? public class SortTest { public static void main(String[] args) { Object[] sa = { 100, 100.0, "100" }; Collections.sort(Arrays.asList(sa), null); System.out.println(sa[0]+" "+sa[1]+" "+sa[2] ); }}Select 1 option(s): 100 100 100.0 100.0 100 100 100 100.0 100 It will not compile. It will throw an exception at run time.15. Question: Given:int[][] orig = { { 1, 2, 3} , { 4, 5, 6, 7}};int[][] dup = orig.clone();int[] copy = dup[0].clone();System.out.println(orig == dup);System.out.println(orig.equals(dup));System.out.println(orig[0] == dup[0]);System.out.println(dup[0] == copy);System.out.println(dup[0].equals(copy));How many times will true be printed?Select 1 option(s): 0 1 2 3 4 516. Question: Given:module broker{ exports org.broker.api; provides org.broker.api.Broker with org.broker.api.MyBroker}Which of the following statements are correct?Select 3 option(s): This is not a valid service definition module because it provides the service instead of defining it. This is not a valid service provider module because it does not contain appropriate requires clause for service definition. Other modules can also provide implementations for org.broker.api.Broker service. Placing the org.broker.api package in a separate module named brokerapi would make it easy to install multiple provider modules. It is not a good idea to include MyBroker and Broker in the same module because that allows the user of the service to inadvertantly depend on the implementation class.17. Question: What would be the result of trying to compile and run the following program? public class Test{ int[] ia = new int[1]; Object oA[] = new Object[1]; boolean bool; public static void main(String args[]){ var test = new Test(); System.out.println(test.ia[0] + " " + test.oA[0]+" "+test.bool); }}Select 1 option(s): The program will fail to compile, because of uninitialized variable 'bool'. The program will throw a java.lang.NullPointerException when run. The program will print "0 null false". The program will print "0 null true". The program will print null and false but will print junk value for ia[0].18. Question: Consider the following interface definition:interface Measurement{ public default int getLength(){ System.out.println("getting length"); return 10; }; public default int getBreadth(){ System.out.println("getting length"); return 20; };}Several similar default methods need to be added to this interface and each method is supposed to log a message at the start of the method. As of now, the logging is done using just a println statement but it may change later.What changes can be done in the above interface to make it more maintainable without exposing any non-business functionality to the users of this interface?Select 1 option(s): Add a public void log(String msg) method to write the log message and invoke it from other methods instead of using println statement. Add a protected void log(String msg) method to write the log message and invoke it from other methods instead of using println statement. Add a private void log(String msg) method to write the log message and invoke it from other methods instead of using println statement. Add a static void log(String msg) method to write the log message and invoke it from other methods instead of using println statement.19. Question What will the following code print when run? String[] sa = { "charlie", "bob", "andy", "dave" }; Collections.sort(Arrays.asList(sa), null); System.out.println(sa[0]);Select 1 option(s): charlie andy dave It will throw a NullPointerException It will not compile.20. Question: What will the following code NEVER print when run? enum SIZE{ TALL, JUMBO, GRANDE;}class CoffeeMug{ public static void main(String[] args) { var hs = new HashSet<SIZE>(); hs.add(SIZE.TALL); hs.add(SIZE.JUMBO); hs.add(SIZE.GRANDE); hs.add(SIZE.TALL); hs.add(SIZE.TALL); hs.add(SIZE.JUMBO); for(SIZE s : hs) System.out.print(s+" "); }}Select 2 option(s): GRANDE TALL JUMBO TALL JUMBO GRANDE TALL GRANDE JUMBO TALL JUMBO GRANDE TALL TALL JUMBO TALL JUMBO GRANDE TALL JUMBO21. Question: What can be inserted in the following code so that it will print 12? public class TestClass{ interface Doer{ String doIt(int x, String y); } public static void main(String[] args) { INSERT CODE HERE System.out.println(d.doIt(2, "12345")); }}Select 2 option(s): int a; String b; Doer d = (a, b)->b.substring(0, a); int a = 0; String b = ""; Doer d = (a, b)->b.substring(0, a); Doer d = (a, b)->b.substring(0, a); Doer d = (int a, String b)->b.substring(0, a); Doer d = a, b->b.substring(0, a);22. Question: When is the Object created at line //1 eligible for garbage collection? public class TestClass{ public Object getObject(){ Object obj = new String("aaaaa"); //1 Object objArr[] = new Object[1]; //2 objArr[0] = obj; //3 obj = null; //4 objArr[0] = null;//5 return obj; //6 }}Select 1 option(s): Just after line 2. Just after line 3. Just after line 4. Just after line 5. Just after line 6.23. Question: Given:public class Student { private String name; private int marks; //constructor and getters and setters not shown public void addMarks(int m){ this.marks += m; } public void debug(){ System.out.println(name+":"+marks); }}What will the following code print when compiled and run?List<Student> slist = List.of(new Student("S1", 40), new Student("S2", 35), new Student("S3", 30));Consumer<Student> increaseMarks = s->s.addMarks(10);slist.forEach(increaseMarks);slist.forEach(Student::debug);Select 1 option(s): S1:50 S2:45S3:40 S1:40 S2:35S3:30 It will not print anything. It will not compile.24. Question: java.util.Locale allows you to do which of the following? Select 2 option(s): Provide country specific formatting for fonts. Provide country and language specific formatting for HTML pages. Provide country and language specific formatting for Dates. Provide country specific formatting for Currencies. Provide country and language specific formatting for properties files.25. Question: What will the following code fragment print? Path p1 = Paths.get("x\\y"); Path p2 = Paths.get("z"); Path p3 = p1.relativize(p2); System.out.println(p3);Select 1 option(s): 26. Question: What is the result of executing the following fragment of code: boolean b1 = false;boolean b2 = false;if (b2 != b1 = !b2){ System.out.println("true");}else{ System.out.println("false");}Select 1 option(s): Compile time error. It will print true. It will print false. Runtime error. It will print nothing.27. Question: What will the following code print when compiled and run? public class Test{ static int a = 0; int b = 5; public void foo(){ while(b>0){ b--; a++; } } public static void main(String[] args) { var p1 = new Test(); p1.foo(); var p2 = new Test(); p2.foo(); System.out.println(p1.a+" "+p2.a); }}Select 1 option(s): 0 10 10 10 10 0 5 5 0 5 5 028. Question: Consider the following code:class A{ byte getStatusCode(Object obj) throws NullPointerException { if(obj != null ) return 128; else return -1; }}class B extends A{ //override getStatusCode method.}Which of the following statements are valid?Select 3 option(s): Overriding method cannot throw IOException Overriding method can throw Throwable class A will not compile as it is. Overriding method can throw any exception Overriding method may choose not to throw any exception.29. Question: Consider the following code appearing in Eagle.javaclass Bird { private Bird(){ }}class Eagle extends Bird { public String name; public Eagle(String name){this.name = name;}public static void main(String[] args) {System.out.println(new Eagle("Bald Eagle").name);}} What can be done to make this code compile?Select 1 option(s): Nothing, it will compile as it is. Make Eagle class declaration public: public class Eagle { ... } Make the Eagle constructor private: private Eagle(String name){ ... } Make Bird constructor public: public Bird() { ... } Insert super(); as the first line in Eagle constructor: public Eagle(String name){super();this.name = name;}30. Question: Given:public class Triangle{ public int base;public int height;public double area; public Triangle(int base, int height){ this.base = base; this.height = height; updateArea();}void updateArea(){ area = base*height/2; }public void setBase(int b){ base = b; updateArea(); }public void setHeight(int h){ height = h; updateArea(); }} The above class needs to protect an invariant on the "area" field. Which three members must have the public access modifiers removed to ensure that the invariant is maintained?Select 3 option(s): the base field the height field the area field the Triangle constructor the setBase method the setHeight method31. Question: What will the following code print when compiled and run: public class TestClass { public static void main(String[] args){ var k = 2; while(--k){ System.out.println(k); } }}Select 1 option(s): 1 10 21 210 It will keep printing numbers in an infinite loop. It will not compile.32. Question: What will the following code print when run?class A {}class AA extends A { }public class TestClass {public static void main(String[] args) throws Exception { A a = new A();AA aa = new AA(); a = aa;System.out.println("a = "+a.getClass());System.out.println("aa = "+aa.getClass()); }}Select 1 option(s): It will not compile. It will throw ClassCastException at runtime. a = class AA aa = class AA a = class A aa = class AA33. Question: Consider the following code: String[] dataList = {"x", "y", "z"}; for (var dataElement : dataList) { int innerCounter = 0; while (innerCounter < dataList.length) { System.out.println(dataElement + ", " + innerCounter); innerCounter++; } }How many times will the output contain 2?Select 1 option(s): 0 1 2 3 4 It will fail to compile.34. Question: What will the following code print when compiled and run? BinaryOperator<String> bo = (s1, s2) -> s1.concat(s2);List<String> names = new ArrayList<>();names.add("Bill"); names.add("George"); names.add("Obama");String finalvalue = names.stream().reduce("Hello : ", bo);System.out.println(finalvalue);Select 1 option(s): Hello : BillGeorgeObama Hello : BillHello : GeorgeHello : Obama BillGeorgeObamaHello : BillGeorgeObama It will throw an exception at run time.35. Question: Given:class MyProcessor{ int value; public MyProcessor(){ value = 10; } public MyProcessor(int value){ this.value = value; } public void process(){ System.out.println("Processing "+value); }}Which of the following code snippets will print Processing 10?Select 2 option(s): Supplier< MyProcessor > supp = MyProcessor::new;MyProcessor mp = supp.get(); mp.process(); Supplier< MyProcessor > supp = MyProcessor::new(10);MyProcessor mp = supp.get();mp.process(); Supplier< MyProcessor > supp = MyProcessor(10)::new;MyProcessor mp = supp.get();mp.process(); Function< Integer, MyProcessor > f = MyProcessor::new;MyProcessor mp = f.apply(10);mp.process(); MyProcessor mp = MyProcessor::new(10);mp.process();36. Question: What will the following method return if called with an argument of 7? public int transformNumber(int n){ var radix = 2; var output = 0; output += radix*n; radix = output/radix; if(output<14){ return output; } else{ output = output*radix/2; return output; } else { return output/2; }}Select 1 option(s): 7 14 49 Compilation fails.37. Question: You have a collection which contains objects of a class X. When the collection is sorted using Collections.sort(collectionOfX);, X's compareTo() method is used. Which of the following statements are correct about this class X?Select 2 option(s): Class X implements Comparator interface. Class X implements Comparable interface. Class X neither implements Comparable nor Comparator. Object of a separate class that implements Comparator is used for sorting. The mechanism used in this situation allows the Objects of class X to be sorted in only one way (and the reverse of that way).38. Question: You are working on an application that is NOT structured as a modular application. However, you need to use a third party library that is packaged as a modular jar named abc.utils.jar in your application.Given that you launch your application using a class named Main, which of the following options should be used to make sure your application is able to access the classes in the third party jar?(Assume that abc.utils.jar and your application classes are in current directory.)Select 1 option(s): Extract the contents of abc.utils.jar in current directory and launch Main like this:java Main java -classpath . -module abc.utils.jar Main java --module-path abc.utils.jar Main java -classpath .;abc.utils.jar Main39. Question: Consider the following program...public class Outer{ private double d = 10.0; //put inner class here.}Which of the following options can be inserted in Outer class?Select 3 option(s): class Inner{public void m1() { this.d = 20.0; } } abstract class Inner {public void m1() { d = 20.0; } } final class Inner{public void m1() { d = 20.0; } } private class Inner{public void m1() { d = 20.0; } }40. Question: Given the following class packaged in a.jar:public class SecureClass1 { public static String getProp(final String propName) { return AccessController.doPrivileged( new PrivilegedAction<String>() { public String run() { return System.getProperty(propName); } }, AccessController.getContext() ); }}A developer has written the following class and packaged it in b.jar. To ensure that SecureClass2 is not able to access any system property, the developer has wrapped the call to doWork within the doPrivileged method and has passed in an AccessControlContext without any permissions.public class SecureClass2 { private static final java.security.PermissionCollection noPermissions = new java.security.Permissions(); private static final AccessControlContext noPermissionsAcc = new AccessControlContext( new ProtectionDomain[] { new ProtectionDomain(null, noPermissions) } ); public static void doWork(final String propName){ AccessController.doPrivileged( new PrivilegedAction<Void>() { public Void run() { System.out.println("In SecureClass2 : "+SecureClass1.getProp(propName)); return null; } }, noPermissionsAcc); } public static void main(String[] args) { SecureClass2.doWork(args[0]); }}Another developer executes SecureClass2 with a policy file containing the following permission:grant codeBase "file:c:\\temp\\a.jar" { permission java.util.PropertyPermission "java.home", "read";};Assuming that both the jars are in the classpath and that SecureClass2 is executed from the command line with a SecurityManager present, identify the correct statement(s).Select 1 option(s): A java.security.AccessControlException will be thrown from SecureClass1.getProp() because the caller method has no permissions. To make it work, the policy file must also contain : grant codeBase "file:c:\\temp\\b.jar" {permission java.util.PropertyPermission "java.home", "read"; }; To make it work, the policy file requires only the following:grant codeBase "file:c:\\temp\\b.jar" { permission java.util.PropertyPermission "java.home", "read"; }; The approach taken by the developer will not prevent the code from accessing the java.home system property.41. Question: What will the following code most likely print when compiled and run? List<String> names = Arrays.asList("greg", "dave", "don", "ed", "fred" );Map<Integer, Long> data = names.stream().collect(Collectors.groupingBy( String::length, Collectors.counting()) );System.out.println(data.values());Select 1 option(s): [1, 1, 3] [1, 2, 3] [2, 3, 4] ["greg", "dave", "don", "ed", "fred"] The data variable should be declared of type Map< Integer, Integer > for the code to compile. The data variable should be declared of type Map<Long, Long> for the code to compile.42. Question: Consider the following code snippet://INSERT LINE OF CODE HERE switch( condition ){ case 1 : System.out.println("1"); break; case 2 : System.out.println("2"); break; case 3 : System.out.println("3"); break; }What type can be inserted in the code above so that the above code compiles and runs as expected ?Select 2 option(s): int condition; long condition = 2; var condition = new Integer("1"); String condition = "1"; var condition = new Short(1); Byte condition = 1;43. Question: Given the following module-info:module book{ requires org.pdf; uses org.pdf.Print;}Which of the following statements are correct?Select 1 option(s): book module can be compiled without requiring any module that provides Print service. At least one implementation of Print service must be available on module-source-path for book module to compile. At least one implementation of Print service must be available for book module to execute without an exception. At least one implementation of Print service must be available for book module to load successfully at run time. The requires org.pdf; clause in the given module-info is redundant.44. Question: Which line, if any, will give a compile time error ?void test(byte x){ switch(x){ case 'a': // 1 case 256: // 2case 0: // 3default : // 4case 80: // 5 }}Select 1 option(s): Line 1 as 'a' is not compatible with byte. Line 2 as 256 cannot fit into a byte. No compile time error but a run time error at line 2. Line 4 as the default label must be the last label in the switch statement. There is nothing wrong with the code.45. Question: Given:module abc.print{ requires org.pdf; provides org.pdf.Print with com.abc.print.SimplePrintImpl; provides org.pdf.Print with com.abc.print.ComplexPrintImpl;}Assuming that another module named book uses abc.print module and contains the following code, ServiceLoader<Print> psLoader = ServiceLoader.load(Print.class); for (Print p : psLoader){ p.print("Hello"); }identify correct statements.Select 1 option(s): Only the print method from SimplePrintImpl will be invoked. Only the print method from ComplexPrintImpl will be invoked. print methods from SimplePrintImpl as well as ComplexPrintImpl will be invoked. abc.print module will not compile. An exception will be thrown at run time when the given code is executed.46. Question: Which of these expressions will return true? Select 4 option(s): "hello world".equals("hello world") "HELLO world".equalsIgnoreCase("hello world") "hello".concat(" world").trim().equals("hello world") "hello world".compareTo("Hello world") < 0 "Hello world".toLowerCase( ).equals("hello world")47. Question: Which of the following are valid? (Assume the method bodies are valid.)Note: The topic of generics is not mentioned in exam objectives. However, we have seen candidates getting questions that expect basic idea of generics. It is possible that such questions are unscored (i.e. your answer to these questions are not considered while computing your final score.)Select 3 option(s): BiFunction<Integer, Integer, Double> bf = (a, b)->a/b; public BiFunction<Integer, String, Double> getBF(){ ... } class Transformer< T >{public BiFunction<T, T, T> getMethod(){ ... } } BiFunction<int, int, int> bf = (a, b)->a/b; <A, B, C> BiFunction<A, B, C> predicate(Function<A, B> f){ ... }48. Question: Which of the following activities are potential targets of denial of service attacks? Select 1 option(s): Printing low level exception messages from infrstructural libraries in log files. Sloppy format validation for input values. Allowing any one to create instances of a class by making the class's constructors public. Not defining the serialPersistentFields array field appropriately for a Serializable class. Java deserialization and Java Beans XML deserialization of data.49. Question: Given ://In Data.javapublic class Data{ int value; Data(int value){ this.value = value; }}and the following code fragments:public void printUsefulData(ArrayList<Data> dataList, Predicate<Data> p){ for(Data d: dataList){ if(p.test(d)) System.out.println(d.value); }}.... ArrayList<Data> al = new ArrayList<Data>(); al.add(new Data(1));al.add(new Data(2));al.add(new Data(3)); //INSERT METHOD CALL HEREWhich of the following options can be inserted above so that it will print 3?Select 2 option(s): printUsefulData(al, (Data d)-> { return d.value>2; } ); printUsefulData(al, d-> d.value>2 ); printUsefulData(al, (d)-> return d.value>2; ); printUsefulData(al, Data d-> d.value>2 ); printUsefulData(al, d -> d.value>2; );50. Question: Given ://1public class TestClass {//2 public static void main(String[] args) throws Exception{ var al = new ArrayList<Integer>(); printElements(al); }//3 static void printElements(List<Integer>... la) { for(List<Integer> l : la){ System.out.println(l); } }}Which option(s) will get rid of compilation warning(s) for the above code?Select 1 option(s): Apply @SuppressWarnings("all") at //1 Apply @SuppressWarnings("unchecked") at //2 Apply @SuppressWarnings("rawtypes") at //2 Apply @SuppressWarnings("rawtypes") at //3 Apply @SuppressWarnings("unchecked") at //2 as well as //3. Apply @SuppressWarnings("rawtypes") at //2 as well as //3.51. Question: Given:module abc.blogger { requires serviceapi; provides api.BloggerService with abc.SimpleBlogger;}Which of the following code fragments appearing in another module correctly loads a service provider that implements api.BloggerService?Select 1 option(s): BloggerService blogger = BloggerService.getInstance(); ServiceLoader< BloggerService > bsLoader = ServiceLoader.load(BloggerService.class); BloggerService bs = bsLoader.findFirst(); api.BloggerService bloggerServiceRef = abc.SimpleBlogger() api.BloggerService bloggerServiceRef = ServiceLoader.get(abc.SimpleBlogger.class) ServiceLoader< BloggerService > bsLoader = ServiceLoader.load(BloggerService.class);bsLoader.forEach(bs->bs.blog("hello"));(Assuming that BloggerService has a blog(String ) method.)52. Question: What will the following code print when run? class Baap { public int h = 4; public int getH() { System.out.println("Baap " + h); return h; }}public class Beta extends Baap { public int h = 44; public int getH() { System.out.println("Beta " + h); return h; } public static void main(String[] args) { Baap b = new Beta(); System.out.println(b.h + " " + b.getH()); Beta bb = (Beta) b; System.out.println(bb.h + " " + bb.getH()); }}Select 1 option(s): Beta 44 4 44Baap 4444 44 Baap 44 4 44Beta 44 44 44 Beta 444 44 Beta 444 44 Beta 444 44 Beta 4444 4453. Question: What will the following code print? List s1 = new ArrayList( );s1.add("a");s1.add("b");s1.add("c");s1.add("a");System.out.println(s1.remove("a")+" "+s1.remove("x"));Select 1 option(s): 1 0 2 -1 2 0 1 -1 true falseTime is Up!