APCSA MCQPacket Unit 7-10

APCSA MCQPacket Unit 7-10

Assessment

Flashcard

Computers

11th Grade

Practice Problem

Hard

Created by

Wayground Content

FREE Resource

Student preview

quiz-placeholder

34 questions

Show all answers

1.

FLASHCARD QUESTION

Front

Consider the following code segment. What is printed as a result of executing the code segment? Options: , , , , Nothing is printed because the first print statement will cause an error.

Media Image

Back

Media Image

2.

FLASHCARD QUESTION

Front

Refer to the static method removeNegs shown below. For which of the following lists will the method not work as intended? 6 -1 -2 5, -1 2 -3 4, 2 4 6 8, -3, 1 2 3 -8

Media Image

Back

6 -1 -2 5

3.

FLASHCARD QUESTION

Front

Consider a sorted array arr of n elements, where n is large and n is even. Under which conditions will a linear search of arr be faster than a binary search? I. The target is not in the list. II. The target is in the first position of the list. III. The target is in arr [l + n/2]

Back

II only

4.

FLASHCARD QUESTION

Front

Let list be an ArrayList<String> containing only these elements: “Alex”, “Emma”, “John”, “Luis”. Which of the following statements will cause an error to occur? I. list.set(2, “6”); II. list.add(4, “Steven”); III. String s = list.get(4);

Back

III only

5.

FLASHCARD QUESTION

Front

Consider a Monster class that has a default constructor. Suppose a list ArrayList<Monster> minions is initialized. Which of the following will not cause an IndexOutOfBoundsException to be thrown?
Options:
for(int i = 0; i <= minions.size(); i++) minions.set(i, new Monster());
minions.add(minions.size(), new Monster());
Monster m = minions.get(minions.size());
Monster m = minions.remove(minions.size());
minions.add(-1, new Monster());

Back

minions.add(minions.size(), new Monster());

6.

FLASHCARD QUESTION

Front

A sorted list of 200 integers is to be searched to determine whether the value of 150 is in the list. What is the most efficient sorting algorithm to use in this case and what is the maximum number of elements that would be examined?

Back

Binary Search, 8 times

7.

FLASHCARD QUESTION

Front

What element will be contained in nums[2] after executing the shuffle algorithm on the array nums = 8, 7, 6, 5, 4 with rand values 3, 2, 0, 0?

Media Image

Back

8

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?