Question

What will be the output of the following Java code snippet, which implements a simple ArrayList and performs an insertion and a retrieval? import java.util.*;                             public class TestArrayList {     public static void main (String[] args) {         ArrayList list = new ArrayList ();         list.add( 10 );         list.add( 20 );         list.add( 30 );         list.add( 1 , 15 );  // Inserting 15 at index 1         System.out.println(list.get( 2 ));     }}

A 15
B 20
C 10
D 30
E Runtime exception
Practice Next

Hey! Ask a query