Multiple Choice Question

Quiz Guidelines

 

QID: 
230
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<String> al = new ArrayList<String>();
al.add("111");
al.add("222");
System.out.println(al.get(al.size()));
}
}

Select 1 option

A. It will not compile.
B. It will throw a NullPointerException at run time.
C. It will throw an IndexOutOfBoundsException at run time.
D. 222
E. null

Q&A Set: 

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!