Question: What will the following program print when compiled and run? Select the two correct answers. (a) (1) will print [Anna, Ada, Bob, null]. (b) (1)
What will the following program print when compiled and run?
![import java.util.ArrayList; import java.util.List; public class RQ12A15 ( public static void main(String[]](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1706/9/5/6/36765be164f22b7c1706956365805.jpg)
Select the two correct answers.
(a) (1) will print [Anna, Ada, Bob, null].
(b) (1) will print [Anna, adA, Bob, null].
(c) (2) will print [Anna, Ada, Bob].
(d) (2) will print [Bob, Ada, Anna].
(e) The program will throw an IndexOutOfBoundsException at runtime.
import java.util.ArrayList; import java.util.List; public class RQ12A15 ( public static void main(String[] args) { doItl (); doIt2 (); } public static void doItl () { List sbListone = new ArrayList (); sbListOne.add(new StringBuilder ("Anna")); sbList One.add(new StringBuilder ("Ada")); sbListOne.add (new StringBuilder ("Bob")); List sbList Two new ArrayList (sbListOne); sbListOne.add(null); (1) } } (2) sbListTwo.get (1).reverse(); System.out.println (sbListOne); public static void doIt2 () { List listone = new ArrayList (); listOne.add ("Anna"); listOne.add("Ada"); listOne.add("Bob"); List listTwo = new ArrayList (listOne); String strTemp = listOne.get (0); listone. set (0, listOne.get (listOne.size () -1)); listOne. set (listOne.size ()-1, strTemp); System.out.println (list Two); //
Step by Step Solution
3.29 Rating (170 Votes )
There are 3 Steps involved in it
b and c In the method doIt1 one of the common elements Ada ... View full answer
Get step-by-step solutions from verified subject matter experts
