zuai-logo
zuai-logo
  1. AP Computer Science A
FlashcardFlashcardStudy GuideStudy GuideQuestion BankQuestion Bank

ArrayList in AP Computer Science A

Question 1
Computer Science AAPExam Style
1 mark

Which of the following loops is the correct way to iterate through an ArrayList<String> called names and print each name?

Question 2
Computer Science AAPExam Style
1 mark

What happens when you attempt to modify the size of an ArrayList (e.g., adding or removing elements) while traversing it using a for-each loop?

Question 3
Computer Science AAPExam Style
1 mark

What is the purpose of the size() method in the ArrayList class?

Question 4
Computer Science AAPExam Style
1 mark

When is it NOT appropriate to use a for-each loop to traverse an ArrayList?

Question 5
Computer Science AAPExam Style
1 mark

Given an ArrayList<String> called names, what will be the output of names.size() after the following operations? names.add("Alice"); names.add("Bob"); names.remove(0);

Question 6
Computer Science AAPExam Style
1 mark

Which of the following is NOT a recommended step for programmers to safeguard users' personal privacy?

Question 7
Computer Science AAPExam Style
1 mark

Which of the following is the correct way to instantiate an ArrayList that holds Integer objects?

Feedback stars icon

How are we doing?

Give us your feedback and let us know how we can improve

Question 8
Computer Science AAPExam Style
1 mark

Consider the following code snippet:

java
ArrayList<Integer> numbers = new ArrayList<>();
numbers.add(10);
numbers.add(20);
numbers.add(30);
numbers.set(1, 40);
numbers.remove(0);
System.out.println(numbers.get(1));

What will be prin...

Question 9
Computer Science AAPExam Style
1 mark

Which of the following code snippets correctly converts an ArrayList<Integer> called list to an Integer[] array?

Question 10
Computer Science AAPExam Style
1 mark

What is the primary ethical concern related to the collection of user data using ArrayLists or other data structures?