Limited access

Upgrade to access all content for this subject

Consider the following declaration and initialization statements. Assume that Baby is a valid class and the Baby instantiation statement is valid.

ArrayList<Object> list1 = new ArrayList<Object>();
List<Baby> list2 = new ArrayList<Baby>();
ArrayList list3 = new ArrayList();
Object[] arr1 = new Object[10];
Baby[] arr2 = new Baby[10];
Baby baby = new Baby("Johnny", "Doe", 8.2, "M");

Which of the following statements will NOT compile and will result in an error?

A
list1.add(baby);
B
list2.add(baby);
C
list3.add(baby);
D
arr1[0] = new baby;
E
arr2[0] = baby;
Select an assignment template