
2026 AP CSA Practice Exam
Authored by Levi Osborne
Computers
University
Used 9+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
36 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
int w = 50;
int x = 20;
int y = x;
x = w;
w = x + y;
System.out.println(w + " " + x);
40 20
70 20
70 50
100 50
2.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
A student is developing a program that will store information about players of a video game, including each player’s score and amount of time remaining, in seconds. Which of the following is the most appropriate design?
An Information class with Player instance variables for the score and the amount of time remaining
A Player class with int instance variables for the score and the amount of time remaining
A Player class, a Score class, and a RemainingTime class, each with an int instance variable
A Score class and a RemainingTime class, each with a Player instance variable
3.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Which of the following expressions evaluates to 3.5?
(double) 2 / 4 + 3
(double) 2 / (4 + 3)
(double) (2 / 4) + 3
(double) (2 / 4 + 3)
4.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
String oldStr = "ABCDEF";
String newStr = /* missing code */;
System.out.println(newStr);
Which of the following expressions can be used to replace /* missing code */ so that the code segment prints the string "BCEF"?
oldStr.substring(1, 2) + oldStr.substring(4)
oldStr.substring(1, 2) + oldStr.substring(5)
oldStr.substring(1, 3) + oldStr.substring(4)
oldStr.substring(1, 3) + oldStr.substring(5)
5.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Consider the following partial class definition.
Assume that SomeClass object obj has been properly declared and instantiated in a class other than SomeClass.
Which of the following statements will compile without error?
int x = obj.getA();
int x = obj.myA;
int x = SomeClass.getA();
int x = getA(obj);
6.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Which of the following methods can be added to SomeClass to allow other classes to modify the value of myA?
public void setA(int newA)
{ myA = newA;
}
private void setA(int newA)
{ myA = newA;
}
public void setA(int newA)
{ newA = myA;
}
private void setA(int newA)
{ newA = myA;
}
7.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
The following categories are used by some researchers to categorize regions as urban, suburban, or rural based on
population density.
• An urban region is a region with more than 3,000 people per square mile.
• A suburban region is a region with between 1,000 and 3,000 people, inclusive, per square mile.
• A rural region is a region with fewer than 1,000 people per square mile.
Consider the following method, which is intended to categorize a region as urban, suburban, or rural based on the
population density of the region.
public static String getCategory(int density)
{
/* missing code */
}
Which of the following code segments can replace /* missing code */ so the getCategory method works as
intended?
String category;
if (density > 3000)
{ category = "urban";
}else if (density >= 1000)
{ category = "suburban";
} else {
category = "rural";
}
return category;
String category;
if (density > 3000)
{ category = "urban";
} else if (density <= 3000)
{ category = "suburban";
} else {
category = "rural";
}
return category;
String category = "rural";
if (density > 3000)
{ category = "urban";
}
if (density >= 1000)
{ category = "suburban";
}
return category;
String category = "urban";
if (density < 1000)
{ category = "rural";
}
if (density >= 1000)
{ category = "suburban";
}
return category;
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?