Multiple Choice Question

Quiz Guidelines

 

QID: 
239
Tags: 
Question: 

What will the following code print when compiled and run?

import java.util.*;
public class TestClass {
    public static void main(String[] args) throws Exception {
        ArrayList<Integer> al = new ArrayList<>(); //1
        al.add(111); //2
        System.out.println(al.get(al.size()));  //3
     }
}

Select 1 option

A. It will not compile.
B. It will throw an exception at run time because of line //1
C. It will throw an exception at run time because of line //2 
D. It will throw an exception at run time because of line //3
E. null.

Q&A Set: