Q. What will be the output of the following code

Code:
import java.util.ArrayList;
import java.util.List;

public class ArrayListTest {
public static void main(String args[])
{
List<String> arrayList=new ArrayList<String>();

arrayList.add(“a”);
arrayList.add(“b”);
arrayList.add(“c”);

System.out.println();
arrayList.add(1,”d”);
System.out.println(arrayList);
}

}
  • (A) [a, d, b, c]
  • (B) [a, b, c, d]
  • (C) [d, a, d, c]
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (A) [a, d, b, c]

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
252
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Pradeep Sikarwar
Publisher
πŸ“ˆ
88%
Success Rate