• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 82 pages
Exam (elaborations)

AP Computer Science A 2026 | Java Programming Study Guide, Practice Questions, Answers, Rationales & Exam Review

Document preview thumbnail
Preview 4 out of 82 pages

Prepare for AP Computer Science A with focused study material covering Java programming, object-oriented programming, classes and objects, methods, arrays, ArrayList, inheritance, algorithms, data structures, and problem-solving. Includes practice questions, answers, and rationales to reinforce programming concepts and support effective AP CSA exam preparation and review.

Content preview

AP Computer Science A
2026 | Java Programming
Study Guide, Practice
Questions, Answers,
Rationales & Exam Review
| Complete Ethics Study
Guide




Updated 2026 Questions and Answers
100% Verified Exam Prep and Comprehensive
Rationales
Included

,Consider the following code segment. D.
System.out.println("W"); W
System.out.println("X"); X
System.out.print("Y"); YZ
System.out.print("Z");
What is printed as a result of executing the code segment?


Consider the following code segment. B. cat dog
System.out.print("cat "); horse
System.out.println("dog "); cow
System.out.println("horse ");
System.out.print("cow ");
What is printed as a result of executing the code segment?


Consider the following code segment. D. Hello!How
System.out.print("Hello!"); are you?
System.out.println("How ");
System.out.print("are ");
System.out.print("you?");
What is printed as a result of executing the code segment?


Consider the following code segment. D. Changing print in line 2 to println
System.out.println(hello); // Line 1
System.out.print(world); // Line 2
The code segment is intended to produce the following
output but does not work as intended.
hello
world
Which of the following changes can be made so that the
code segment produces the intended output?


Consider the following code segment. A. Changing print to println in lines 1 and 2
System.out.print("Ready"); // Line 1
System.out.print("Set"); // Line 2
System.out.print("Go!"); // Line 3
The code segment is intended to produce the following
output but may not work as intended.
Ready
Set
Go!
Which change, if any, can be made so that the code
segment produces the intended output?


Each of the following code segments is intended to print A. I only
the word Hello. Which of the following code segments
works as intended?
I. System.out.print("Hello");
II. System.out.print(Hello);
III. System.out.print(He);
System.out.print(llo);


Which statement correctly declares a variable that can B. double patientTemp;
store a temperature rounded to the nearest tenth of a
degree?


A teacher determines student percentages in a course as C. int totalPoints;
the points a student earns divided by the total points double percentage;
available in the grading period. Points are awarded only in
whole number increments, but student percentages are to
be stored as decimals.
The following code segment appears in a program used to
compute student percentages. Points that a student earns
are stored in pointsEarned, the total points available in the
grading period are stored in totalPoints, and the student
percentage is stored in percentage.
int pointsEarned;
/ missing code /
Which of the following is most appropriate to replace
/ missing code / in the program?

,Consider the following code segment: D. The variable x should be declared as a double and the variable y should be
/ data type 1 / x = 0.5; declared as a boolean.
/ data type 2 / y = true;
Which of the following best describes the data types that
should be used to replace/ data type 1 / and / data type
2 / so that the code segment compiles without error?


Consider the following code segment. D. x + 1
int x;
int y;
x = 3;
y = / missing expression /;
x = 1 + 2 * y;
System.out.print(x);
System.out.println(y);
Which of the following can be used as a replacement for
/ missing expression / so that the code segment prints 94
?


The volume of a cylinder is equal to the height times the E. I, II, and III
area of the circular base. The area of the circular base is
equal to π (pi) times the square of the radius.
The code segment below is intended to compute and print
the volume of a cylinder with radius r and height h. Assume
that the double variables r, h, and pi have been properly
declared and initialized.
/ missing code /
System.out.print(volume);
Which of the following can be used to replace / missing
code / so that the code segment works as intended?
I. double baseArea = pi r r;double volume = baseArea * h;
II. double volume = pi r r;volume = volume * h;
III. double volume = pi r r * h;


Consider the following code segment. B. II only
int x = 10;
int y = 20;
/ missing code /
System.out.print(top / bottom);
Which of the following replacements for / missing code /
will cause an ArithmeticException to occur?
I. int top = x - y;int bottom = y - x;
II. int top = 2 * x;int bottom = y - top;
III. int top = x + y;int bottom = 2 * top;




Consider the following code segment. C. 3.0
int a = 1;
int b = 2;
int c = 3;
int d = 4;
double x = a + b * c % d;
What is the value of x when the code segment has been
executed?

, Which of the following arithmetic expressions evaluates to D. II and III only
1?
I. % 3
II. 2 / (5 % 3)
III. + 1


Consider the code segment below. D. 20
int x = 10;
int y = 20;
System.out.print(y + x / y);
What is printed as a result of executing the code segment?


Consider the following code segment. E. 12 20
int j = 10;
int k = 8;
j += 2;
k += j;
System.out.print(j);
System.out.print(" ");
System.out.println(k);
What is printed when the code segment is executed?


Consider the following code segment. E. 4
int x = 0;
x++;
x += 1;
x = x + 1;
x -= -1;
System.out.println(x);
What is printed when the code segment has been
executed?


Consider the following code segment. C. 4
int num = 5;
num *= 2;
num %= 6;
What is the value of num after the code segment is
executed?


Consider the following code segment. D. It sets z to (x / y) + 2.
int x = / initial value not shown /;
int y = / initial value not shown /;
int z = x;
z /= y;
z += 2;
Which of the following best describes the behavior of the
code segment?


Consider the following code segment, which is intended to C. The code segment stores 17.5 in avg because 17.5 is the result of the floating
calculate the average of two quiz scores. point division of 35.0 by 2.
double avg = 15 + 20;
avg /= 2;
Which of the following best describes the behavior of the
code segment?


Consider the following code segment. B. Both the value of x and the value of y have been decreased.
int x = 4;
int y = 6;
x -= y;
y += x;
Which of the following best describes the behavior of the
code segment?

Document information

Uploaded on
September 7, 2026
Number of pages
82
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$10.99

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

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.
Docmaster20
4.3
(6)
Sold
33
Followers
2
Items
2733
Last sold
10 hours ago



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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions