professor-curious-logo
professor-curious-logo
  1. AP Computer Science A
FlashcardFlashcardStudy GuideStudy GuideQuestion BankQuestion Bank
GlossaryGlossary

ArrayList in AP Computer Science A

Question 1
college-boardComputer Science AAPExam Style
1 mark

When trying to retrieve an element from an ArrayList at a certain index, which exception is thrown if the index is out of bounds?

Question 2
college-boardComputer Science AAPExam Style
1 mark

What is an advantage of using separate methods within a class to perform different tasks in a program?

Question 3
college-boardComputer Science AAPExam Style
1 mark

When removing elements from an ArrayList within a loop, which type of loop reduces the likelihood of encountering index out-of-bounds errors or skipping elements?

Question 4
college-boardComputer Science AAPExam Style
1 mark

What does the get(int index) method of an ArrayList return?

Question 5
college-boardComputer Science AAPExam Style
1 mark

Given an abstract class 'Shape' with subclasses 'Circle', 'Rectangle', etc., if you have an ArrayList shapes where elements need casting before specific methods can be called, how do you avoid ClassCastException?

Question 6
college-boardComputer Science AAPExam Style
1 mark

How can you determine if an ArrayList named “inventory” contains a specific item known as “widget”?

Question 7
college-boardComputer Science AAPExam Style
1 mark

How do you retrieve an element from an ArrayList at a given position?

Feedback stars icon

How are we doing?

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

Question 8
college-boardComputer Science AAPExam Style
1 mark

How do you retrieve the element at the third position of an ArrayList named "myList"?

Question 9
college-boardComputer Science AAPExam Style
1 mark

Given ArrayList<String> words = new ArrayList<>(Arrays.asList("apple","banana","cherry","date"));, which modification would reverse their order to [“date”,”cherry”,”banana”,”apple”] using minimal calls to ArrayList methods?

Question 10
college-boardComputer Science AAPExam Style
1 mark

After executing ArrayList<String> colors = new ArrayList<>(Arrays.asList("red", "green", "blue")); , what does colors.get(1) return?