MCQ / Newest 2025 Actual Exam / Questions and
Correct Detailed Answers (Verified Answers)
Terms in this set (18)
Consider the following statement, B. new ArrayList<Thing>()
which is intended to create an
ArrayList named a to store only
elements of type Thing. Assume that
the Thing class has been properly
defined and includes a no-
parameter constructor.
ArrayList<Thing> a = / missing
code /;
Which of the following can be used
to replace / missing code / so that
the statement works as intended?
Consider the following statement, C. I and III only
which is intended to create an
ArrayList named numbers that can
be used to store Integer values.
ArrayList<Integer> numbers = /
missing code /;
Which of the following can be used
to replace / missing code / so that
the statement works as intended?
new ArrayList() new
ArrayList<Integer> new
ArrayList<Integer>()
, Consider the following statement, E. ArrayList<String> arrList
which is intended to create an
ArrayList named arrList to store
elements only of type String.
/ missing code / = new
ArrayList<String>();
Which of the following can be used
to replace / missing code / so that
the statement works as intended?
Consider the following code D. [4, 3, 0, 2, 0]
segment.
ArrayList<Integer> nums = new
ArrayList<>();
nums.add(3); nums.add(2);
nums.add(1); nums.add(0);
nums.add(0, 4); nums.set(3, 2);
nums.remove(3); nums.add(2, 0);
Which of the following represents
the contents of nums after the code
segment has been executed?
Consider the following code B. [DI, DI, DA]
segment.
ArrayList<String> syllables = new
ArrayList<String>();
syllables.add("LA"); syllables.add(0,
"DI"); syllables.set(1, "TU");
syllables.add("DA"); syllables.add(2,
syllables.get(0)); syllables.remove(1);
System.out.println(syllables.toStr
ing());
What is printed as a result of
executing the code segment?