Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Question 20 (1 point) Will the following code have a compile error? ArrayLi

ID: 3811822 • Letter: J

Question

Java

Question 20 (1 point)

Will the following code have a compile error?

ArrayList<int> list = new ArrayList<int>();

Question 20 options:

Save

Question 21 (1 point)

Will the following code have a compile error?

ArrayList<String> list = new ArrayList<String>();
list.add(3);

Question 21 options:

Save

Question 22 (1 point)

Will the following code have a compile error?

ArrayList list = new ArrayList();
list.add(3);
list.add("3");

Question 22 options:

Save

Question 23 (1 point)

Will the following code have a runtime error?

Comparable c = new Date();
int i = c.compareTo("time");

Question 23 options:

Save

Question 24 (1 point)

You can substitute a generic type with a primitive data type.

Question 24 options:

Save

Question 25 (1 point)

ArrayList<Integer> is a subtype of ArrayList<Double>.

Question 25 options:

Save

A) Yes B) No

Explanation / Answer

20) Yes. You should use Integer instead of int. int is a primite data type, so it cannot be put in a ArrayList. The correct declaration is ArrayList<Integer> list = new ArrayList<Integer>();

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote