Unit 7: ArrayList
Showing 17 of 17 questions
What is the output of the following code?
What is the output of the following code?
What is the output of the following code?
Which of the following correctly removes all even numbers from an ArrayList<Integer> named nums?
What is the output of the following code?
What is the output of the following code?
What is the output of the following code?
Which of the following correctly declares an ArrayList of integers and adds the value 42?
After the following code, what is the size of the list?\nArrayList<String> list = new ArrayList<String>();\nlist.add("A");\nlist.add("B");\nlist.add("C");\nlist.remove(1);
Which is true about ArrayList compared to arrays?
ArrayList<Integer> stores Integer objects. Given: list.add(5), how is 5 stored?
Given list = [A, B, C, D], what is the list after list.set(2, "X")?
When removing elements from an ArrayList during traversal with a forward for loop, what common error occurs?
Given list = [A, B, D], what is the result of list.add(2, "C")?
What is the output?\nArrayList<Integer> list = new ArrayList<>();\nfor (int i = 0; i < 5; i++) list.add(i);\nfor (int i = 0; i < list.size(); i++) if (list.get(i) % 2 == 0) list.remove(i);\nSystem.out.println(list);
Consider the following code segment. \nArrayList<Integer> list = new ArrayList<>();\nfor (int i = 1; i <= 5; i++) list.add(i * 10);\nfor (int i = list.size() - 1; i >= 0; i--) { if (list.get(i) % 20 == 0) { list.remove(i); } }\nSystem.out.println(list);
What is the output? ArrayList<Integer> list = new ArrayList<>(); for (int i = 0; i < 6; i++) list.add(i * 2); for (int i = list.size() - 1; i >= 0; i--) { if (list.get(i) % 4 == 0) list.remove(i); } System.out.println(list);
Advertisement