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) NoExplanation / 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>();
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.