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[]

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

1 Expert Approved Answer
Step: 1 Unlock

b and c In the method doIt1 one of the common elements Ada ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Programming 8th Questions!