Question 1 Consider these two ArrayList declarations: ArrayList list1 = new Arra
ID: 3568543 • Letter: Q
Question
Question 1
Consider these two ArrayList declarations:
ArrayList list1 = new ArrayList();
ArrayList<String> list2 = new ArrayList<String>();
Which of the following is a true statement?
1) list1 can hold items of any non-primitive type.
2) list2 can hold only String items
3) both A and B are true
4) none of the above are true
Question 2
Integer as used in the declaration below refers to a __________ type.
ArrayList<Integer> myList = new ArrayList<Integer>();
1) primitive
2) wrapper
3) floating-point
4) unboxed
Question 3
Which of the following code segments prints each item in an ArrayList of Strings? Assume the name of the ArrayList is namesList.
1) for (String name : namesList)
System.out.println(name);
2) for (int i=0; i<namesList.size(); i++)
System.out.println(namesList.get(i));
3) System.out.println(namesList);
4) All of the above.
Explanation / Answer
Question 1:
3)
Question 2:
2)
Question 3:
2)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.