About Question enthuware.ocajp.i.v7.2.870 :
Posted: Wed May 14, 2014 1:39 pm
According to the explanation as I understand it, option#3 is correct but yet it is not. Please explain.
Except:
size() method of ArrayList returns the number of elements. Here, it returns 2. Since numbering in ArrayList starts with 0. al.get(2) will cause an IndexOutOfBoundsException to be thrown because only 0 and 1 are valid indexes for a list of size 2.
Except:
size() method of ArrayList returns the number of elements. Here, it returns 2. Since numbering in ArrayList starts with 0. al.get(2) will cause an IndexOutOfBoundsException to be thrown because only 0 and 1 are valid indexes for a list of size 2.