πŸ“š

Β >Β 

πŸ’»Β 

Β >Β 

πŸ’Ύ

7.9 MC Answers and Review

5 min readβ€’december 24, 2021


AP Computer Science AΒ πŸ’»

130Β resources
See Units

Answers and Review for Multiple Choice Practice on ArrayList

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-OrA4tHUKIEIe.png?alt=media&token=d00c355e-f96c-49e8-a309-819d39c8c69b

Image Fr om Medium.

Β 
β›”STOP!β›” Before you look at the answers make sure you gave this practice quiz a try so you can assess your understanding of the concepts covered in unit 7. Click here for the practice questions: AP CSA Unit 7 Multiple Choice Questions.
Facts about the test: The AP Computer Science A exam has 40 multiple choice questions and you will be given 90 minutes to complete the section. That means it should take you around 34 minutes to complete 15 questions.

*The following questions were not written by CollegeBoard and although they cover information outlined in the AP Computer Science A Course and Exam Description the formatting on the exam may be different.


1. Vehicles are classified based on their total interior volume. The classify method is intended to return a vehicle classification String value based on total interior volume, in cubic feet, as shown in the table (below, see table and sample code). The classify method works as intended for some but not all values of the parameter volume. For which of the following values of volume would the correct value be returned when the classify method is executed?

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-48kJIZKFqZd5.png?alt=media&token=d42cc8e4-de78-454d-86a5-d91ec4ae14df
A. 115
B. 109
C. 105
D. 90
Answer:Β Since 115 is smaller than 120 the first ELSE loop will execute. which will give correct result.
πŸ“„ Study AP CSA, Unit 7.3: Traversing ArrayListΒ 

2. Which of the following is a reason to use an ArrayList instead of an array?

A. An ArrayList can allocate more space than it needs.
B. You can store objects in an ArrayList, but not in an array.
C. An ArrayList can grow or shrink as needed, while an array is always the same size.
D. An ArrayList can grow or shrink as needed, while an array is always the same size.
Answer:Β Main benefit to using an ArrayList.... and every time an ArrayList fills up a new array is created that is twice as big. This can lead to extra space that is wasted.
πŸ“„Β Study AP CSA, Unit 7.1:Β Introduction to ArrayListΒ 

3. What will print when the following code executes?

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-wmvaojt7t3Lw.png?alt=media&token=8034d0fa-3d53-4ac8-9a6d-5811b5006127
A. ["Destini", "Layla", "Sharrie", "Sarah"]
B. ["Sarah", "Layla", "Sharrie"]
C. ["Sarah", "Destini", "Layla", "Sharrie"]
D. ["Sarah", "Destini", "Anaya", "Layla", "Sharrie"]
Answer:Β The list is first ["Anaya", "Layla", "Sharrie"] and then ["Destini, "Layla", "Sharrie"] and finally ["Sarah", "Destini, "Layla", "Sharrie"]
πŸ“„Β Study AP CSA, Unit 7.2:Β ArrayList Methods

4. What will print when the following code executes?

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-iWwvcmqOADlr.png?alt=media&token=cd374224-d415-40c9-af01-857ea88e9375
A. [1, 2, 3, 4, 5]
B. [1, 2, 5, 4, 6]
C. [1, 2, 4, 5, 6]
D. [1, 5, 2, 4, 6]
Answer:Β "add" method that takes an object as a parameter & adds that object to the end of the list. "set" replaces the value at that index with the new value. "add" with index & object parameters puts the passed object at that index and moves any existing values one to the right (increments).
πŸ“„Β Study AP CSA, Unit 7.2:Β ArrayList Methods

5. Given the following code, assume that nums is initially [0, 0, 4, 2, 5, 0, 3], what will nums contain as a result of executing numQuest?

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-CscK5WJsWHn6.png?alt=media&token=2d704e67-40b8-4b10-ae71-edf23b60e0ab
A. [0, 0, 0, 4, 2, 5, 3]
B. [4, 2, 5, 3]
C. [0, 0, 4, 2, 5, 0, 3]
D. [0, 4, 2, 5, 3]
Answer:Β This shows all zeros removed. Since k is only incremented if a value wasn't removed this will work correctly.
πŸ“„Β Study AP CSA, Unit 7.3:Β Traversing ArrayListΒ 

6. Which of the following best describes the behavior of process1 and process2?

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-8TBeqVjAm6ax.png?alt=media&token=7cdee591-0917-45ee-93ae-094e8c0fad29
A. Both methods produce the same result and take the same amount of time.
B. The two methods produce different results and take the same amount of time.
C. The two methods produce different results, and process1 is faster than process2.
D. The two methods produce different results, and process2 is faster than process1.
Answer:Β Both process1 & process2 add to the end of the list each time through the loop. The only difference would be if there were values in the list in process2, existing values would be moved to the right. But, there are no existing values in the list at that index or beyond.
πŸ“„Β Study AP CSA, Unit 7.3:Β Traversing ArrayListΒ 

7. Which of the following best describes a mutable list of object references

A. Method
B. Array
C. ArrayList
D. Object
Answer:Β definition of ArrayList
πŸ“„Β Study AP CSA, Unit 7.1:Β Introduction to ArrayListΒ 

8. Which of the following is a constructor for a new ArrayList?

A. set ArrayList<E>()
B. new ArrayList<E>()
C. new ArrayList {E}()
D. new ArrayList E;
Answer:Β proper syntax
πŸ“„Β Study AP CSA, Unit 7.1:Β Introduction to ArrayListΒ 

9. Which of the following is a common error when trying to modify an ArrayList while using an enhanced for loop.

A. OverflowException
B. runtime error
C. Overflow error
D. ConcurrentModificationException
Answer:Β definition
πŸ“„Β Study AP CSA, Unit 7.1:Β Introduction to ArrayListΒ 

10. Which of the following best describes the information about a person that can be found online?

A. personal privacy
B. personal data
C. security
D. digital footprint
Answer:Β definition of digital footprint
πŸ“„Β Study AP CSA, Unit 7.1:Β Introduction to ArrayListΒ 

11. Which term defines rules and conventions for communication between network devices

A. network protocols
B. network rules
C. device security
D. network footprints
Answer:Β definition of network protocol
πŸ“„Β Study AP CSA, Unit 7.1:Β Introduction to ArrayListΒ 

12. Which of the following terms can be described as a method for finding a target value within a list by sequentially checking each element of the list for the target value until a match is found or until all the elements have been searched.

A. binary search
B. sort protocol
C. linear search
D. parallel search
Answer:Β definition of linear search
πŸ“„Β Study AP CSA, Unit 7.1:Β Introduction to ArrayListΒ 

13. Which of the following terms means to sort an array by repeatedly finding the minimum value, and moving it to the front of the array.

A. MinChoice sort
B. selection sort
C. parallel sort
D. minimum sort
Answer:Β definition of selection sort
πŸ“„Β Study AP CSA, Unit 7.1:Β Introduction to ArrayListΒ 

14. Which of the following correctly illustrates the ArrayList L after the given code segment executes?

https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-Hbayx4EidR8Z.png?alt=media&token=1c1399c2-cdcf-4071-b076-9659ad14406f
A. [!, ?, !, ?, ?]
B. [!, !, ?, !, ?, !]
C. [!, !, ?, !, ?]
D. [!, ?, !, ?, !]
Answer:Β % means remainder when 2 integers are divided: for example 126 % 10 = 6 because 126/10 is 12 with a remainder of 6
πŸ“„Β Study AP CSA, Unit 7.4:Β Developing Algorithms Using ArrayList

15. Which of the following is not a method included in the ArrayList class?

A. int size()
B. int length()
C. Object get(int index)
D. boolean isEmpty()
Answer:Β knowledge relating to ArrayList
πŸ“„Β Study AP CSA, Unit 7.2:Β ArrayList Methods

What can we help you do now?

πŸ” Study for Unit 8
🦘 Jump to AP CSA Unit 8 Multiple Choice Questions
🀝 Connect with other students studying AP CSA with Hours
Browse Study Guides By Unit
βž•Unit 1 – Primitive Types
πŸ“±Unit 2 – Using Objects
πŸ–₯Unit 3 – Boolean Expressions & if Statements
πŸ•ΉUnit 4 – Iteration
βš™οΈUnit 5 – Writing Classes
⌚️Unit 6 – Array
πŸ’»Unit 8 – 2D Array
πŸ–²Unit 9 – Inheritance
πŸ–±Unit 10 – Recursion
πŸ™Exam Reviews