100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

AP Computer Science A Unit 7 Progress Check MCQ Exam Questions and Answers

Rating
-
Sold
-
Pages
7
Grade
A+
Uploaded on
30-07-2024
Written in
2023/2024

AP Computer Science A Unit 7 Progress Check MCQ Exam Questions and Answers

Institution
AP COMPUTER SCIENCE
Course
AP COMPUTER SCIENCE









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
AP COMPUTER SCIENCE
Course
AP COMPUTER SCIENCE

Document information

Uploaded on
July 30, 2024
Number of pages
7
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

AP Computer Science A Unit 7 Progress Check: MCQE Exam
Consider the following statement, which is intended to create an ArrayList named a to store only elements of type Thing. Assume that the Thing class has been properly defined and includes a no-parameter constructor.
ArrayList<Thing> a = /* missing code */;
Which of the following can be used to replace /* missing code */ so that the statement works as intended? - Answer -B. new ArrayList<Thing>()
Consider the following statement, which is intended to create an ArrayList named numbers that can be used to store Integer values.
ArrayList<Integer> numbers = /* missing code */;
Which of the following can be used to replace /* missing code */ so that the statement works as intended?
new ArrayList()
new ArrayList<Integer>
new ArrayList<Integer>() - Answer -C. I and III only
Consider the following statement, which is intended to create an ArrayList named arrList
to store elements only of type String.
/* missing code */ = new ArrayList<String>();
Which of the following can be used to replace /* missing code */ so that the statement works as intended? - Answer -E. ArrayList<String> arrList
Consider the following code segment.
ArrayList<Integer> nums = new ArrayList<>();
nums.add(3);
nums.add(2);
nums.add(1);
nums.add(0);
nums.add(0, 4);
nums.set(3, 2);
nums.remove(3);
nums.add(2, 0);
Which of the following represents the contents of nums after the code segment has been executed? - Answer -D. [4, 3, 0, 2, 0] Consider the following code segment.
ArrayList<String> syllables = new ArrayList<String>();
syllables.add("LA");
syllables.add(0, "DI");
syllables.set(1, "TU");
syllables.add("DA");
syllables.add(2, syllables.get(0));
syllables.remove(1);
System.out.println(syllables.toString());
What is printed as a result of executing the code segment? - Answer -B. [DI, DI, DA]
Consider the following code segment.
ArrayList<Integer> vals = new ArrayList<Integer>();
vals.add(vals.size(), vals.size());
vals.add(vals.size() - 1, vals.size() + 1);
vals.add(vals.size() - 2, vals.size() + 2);
System.out.println(vals.toString());
What is printed as a result of executing the code segment? - Answer -E. [4, 2, 0]
Consider the following code segment.
ArrayList<Integer> myList = new ArrayList();
for (int i = 0; i < 4; i++)
{
myList.add(i + 1);
}
for (int i = 0; i < 4; i++)
{
if (i % 2 == 0)
{
System.out.print(myList.get(i) + " ");
}
}
What output is produced as a result of executing the code segment? - Answer -D. 1 3
Consider the following code segment.
ArrayList<String> words = new ArrayList<String>();
words.add("mat");
words.add("new");
words.add("open");
words.add("pet");

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
millyphilip West Virginia University
View profile
Follow You need to be logged in order to follow users or courses
Sold
2807
Member since
3 year
Number of followers
1960
Documents
40493
Last sold
17 hours ago
white orchid store

EXCELLENCY IN ACCADEMIC MATERIALS ie exams, study guides, testbanks ,case, case study etc

3.7

539 reviews

5
238
4
84
3
104
2
31
1
82

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions