Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

AP COMPUTER SCIENCE PRACTICE EXAM A

Rating
-
Sold
-
Pages
11
Grade
A+
Uploaded on
10-11-2025
Written in
2025/2026

AP COMPUTER SCIENCE PRACTICE EXAM A

Institution
AP COMPUTER SCIENCE
Course
AP COMPUTER SCIENCE

Content preview

AP COMPUTER SCIENCE PRACTICE EXAM A

Consider the following method.

public static int mystery(int[] arr)
{
int x = 0
for (int k = 0; k < arr.length; k = k + 2)
x = x + arr[k]
return x;
}
Assume that the array nums has been declared and initialized as follows.
int[] nums = {3, 6, 1, 0, 1, 4, 2};

(A) 5
(B) 6
(C) 7
(D) 10
(E) 17 - Answer -(C) 7

Consider the following partial class declaration.

public class SomeClass
{
private int myA;
private int myB;
private int myC;
// Constructor(s) not shown
public int getA
{ return myA; }
public void setB(int value)
{ myB = value; }
The following declaration appears in another class.
SomeClass obj = new SomeClass();
Which of the following code segments will compile without error?
(A) int x = obj.getA();
(B) int x;
obj.getA(x);
(C) int x = obj.myA
(D) int x = SomeClass.getA();
(E) int x = getA(obj); - Answer -(A) int x = obj.getA

Which of the following changes to SomeClass will allow other classes to access but not
modify the value of myC ?
(A) Make myC public.

, (B) public int getC()
{ return myC; }

(C) private int getC()
{ return myC; }

(D) public void getC(int x)

(E) private void getC(int x)
{ x = myC; } - Answer -(B) public int getC()
{ return myC; }

Consider the following code segment.
int x = 7;
int y = 3;

if ((x < 10) && (y < 0))
System.out.printIn("Value is: " + x * y);
else
System.out.printIn("Value is: " + x / y);
What is printed as a result of executing the code segment

(A) Value is: 21
(B) Value is: 2.3333333
(C) Value is: 2
(D) Value is: 0
(E) Value is: 1 - Answer -(B) 2.3333333

Consider the following method.
public ArrayList<Integer> mystery(int n)
{
ArrayList<Integer> seq = new ArrayList<Integer>();
for (int k = 1; k <= n; k++)
seq.add(new Integer(k * k + 3));

return seq
}
Which of the folowing is printed as a result of executing the following statement?
System.out.printIn.(mystery(6));
(A) [3, 4, 7, 12, 19, 28]
(B) [3, 4, 7, 12, 19, 28, 39]
(C) [4, 7, 12, 19, 28, 39]
(D) [39, 28, 19, 12, 7, 4]
(E) [39, 28, 19, 12, 7, 4, 3] - Answer -(C) [4, 7, 12, 19, 28, 39]

Written for

Institution
AP COMPUTER SCIENCE
Course
AP COMPUTER SCIENCE

Document information

Uploaded on
November 10, 2025
Number of pages
11
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$14.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

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.
GEEKA YALA UNIVERSITY
View profile
Follow You need to be logged in order to follow users or courses
Sold
2066
Member since
4 year
Number of followers
1446
Documents
51736
Last sold
1 hour ago

3.8

355 reviews

5
177
4
61
3
47
2
17
1
53

Trending documents

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