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 A –QUESTIONS AND CORRECT ANSWERS (VERIFIED ANSWERS) PLUS RATIONALES 2026 Q&A | INSTANT DOWNLOAD PDF.

Rating
-
Sold
-
Pages
43
Grade
A+
Uploaded on
26-05-2026
Written in
2025/2026

AP COMPUTER SCIENCE A –QUESTIONS AND CORRECT ANSWERS (VERIFIED ANSWERS) PLUS RATIONALES 2026 Q&A | INSTANT DOWNLOAD PDF.

Institution
AP COMPUTER SCIENCE A
Course
AP COMPUTER SCIENCE A

Content preview

AP COMPUTER SCIENCE A –QUESTIONS AND CORRECT ANSWERS (VERIFIED ANSWERS) PLUS RATIONALES 2026 Q&A | INSTANT
DOWNLOAD PDF.




*Core Domains*
*- Primitive Types*
*- Using Objects*
*- Boolean Expressions and if Statements*
*- Iteration*
*- Writing Classes*
*- Array*
*- ArrayList*
*- 2D Array*
*- Inheritance*
*- Recursion*
*- Ethical and Social Implications of Computing*


*Introduction*
*The AP Computer Science A assessment is designed to evaluate a candidate's proficiency in core Java programming concepts, object-orien
 




Section One: Questions 1–100
Question 1
Consider the following code segment:
int x = 5;
int y = 2;
double z = x / y;
What is the value of z after the code segment is executed?
A. 2.5
B. 2.0
C. 3.0
D. 0.0

,🟢 B. 2.0
🔴 RATIONALE: In Java, when two integers are divided using the / operator, integer division is performed, which truncates the fractional part.
Therefore, evaluates to 2. This integer result is then implicitly cast to a double when assigned to z, resulting in 2.0.
Question 2
A software company discovers that a legacy module contains a method that can cause an infinite loop if negative parameters are passed.
Modifying the legacy source code directly is prohibited due to strict regression compliance frameworks. Which design strategy represents the
most professional and ethically sound approach to resolve this issue?
A. Document the limitation in the developer user manual and allow the application to crash if negative inputs occur.
B. Implement a wrapper class or a subclass that overrides the method to perform input validation before invoking the legacy code.
C. Use a runtime configuration script to force close the application whenever a negative value is detected anywhere in memory.
D. Ignore the issue because legacy systems are exempt from current software compliance and safety standards.
🟢 B. Implement a wrapper class or a subclass that overrides the method to perform input validation before invoking the legacy code.
🔴 RATIONALE: Software engineering ethics and compliance frameworks require developers to mitigate known safety hazards and
operational risks. Implementing a wrapper class or subclass to intercept and validate input ensures system reliability and safety without
violating structural regression constraints.
Question 3
Consider the following method:
public static int compute(int n) {
if (n <= 1) {
return 1;
} else {
return n + compute(n - 1);
}
}
What value is returned as a result of the call compute(4)?
A. 10
B. 7
C. 24
D. 4
🟢 A. 10
🔴 RATIONALE: This is a recursive method that calculates the sum of integers from 1 to n. The execution path for compute(4) expands to 4
+ compute(3), which becomes 4 + (3 + compute(2)), then 4 + 3 + (2 + compute(1)). Since compute(1) returns 1, the total sum is 4 + 3 + 2 + 1
= 10.
Question 4
Consider the following code segment:
int[] elements = {3, 7, 2, 8, 5};

,int value = elements[1];
for (int i = 2; i < elements.length; i++) {
if (elements[i] > value) {
value = elements[i];
}
}
What is the value of the variable value after this loop executes?
A. 7
B. 2
C. 8
D. 5
🟢 C. 8
🔴 RATIONALE: The variable value is initialized to elements[1], which is 7. The loop iterates from index 2 to the end of the array, comparing
each element to value. It encounters 2 (not greater), 8 (greater, so value becomes 8), and 5 (not greater). The final value is 8.
Question 5
A developer needs to store an ordered list of transactional records where elements are frequently inserted and deleted from the middle of the
collection during runtime. Which data structure from the AP Java subset is most appropriate for optimizing these specific insertions and
deletions?
A. A primitive array
B. An ArrayList
C. A 2D array
D. A static array of objects
🟢 B. An ArrayList
🔴 RATIONALE: An ArrayList dynamically resizes and provides built-in methods (add and remove) to insert and delete elements at any
position. While primitive and static arrays have fixed dimensions that cannot grow or shrink dynamically, ArrayList handles variable-length
transactional data lists.
Question 6
Consider the following class declarations:
public class Vehicle {
public void start() {
System.out.print("V-Start ");
}
}
public class Car extends Vehicle {
public void start() {
super.start();

, System.out.print("C-Start ");
}
}
What is printed when the following code segment is executed?
Vehicle myCar = new Car();
myCar.start();
A. V-Start
B. C-Start
C. V-Start C-Start
D. C-Start V-Start
🟢 C. V-Start C-Start
🔴 RATIONALE: Due to polymorphism, the runtime environment executes the overridden start method in the Car class. Inside Car's start
method, super.start() is called first, which executes Vehicle's start method and prints "V-Start ". Then, the remaining statement in Car's
method prints "C-Start ".
Question 7
Under copyright and intellectual property standards, which of the following actions constitutes a direct violation of professional computing
ethics?
A. Using an open-source library in a commercial application while strictly adhering to its MIT license terms.
B. Modifying a publicly available algorithm to improve its execution time for internal research.
C. Copying a proprietary software library's compiled bytecode and distributing it as part of a commercial product without a license.
D. Writing an original class that implements an interface published in a public documentation standard.
🟢 C. Copying a proprietary software library's compiled bytecode and distributing it as part of a commercial product without a license.
🔴 RATIONALE: Distributing proprietary bytecode without an appropriate commercial license is a clear violation of intellectual property laws
and professional computing ethics. Adhering to open-source licenses, academic modification, and implementing public interfaces are legally
and ethically compliant acts.
Question 8
Consider the following boolean expression where a and b are initialized boolean variables:
!(!a && b)
Which of the following expressions is logically equivalent to the given expression?
A. a || !b
B. a && !b
C. !a || b
D. !a && !b
🟢 A. a || !b
🔴 RATIONALE: Applying De Morgan's Laws to the expression !(!a && b) distributes the negation inside the parentheses. The negation of !a
becomes a, the logical AND (&&) becomes a logical OR (||), and the negation of b becomes !b. This evaluates to a || !b.

Written for

Institution
AP COMPUTER SCIENCE A
Course
AP COMPUTER SCIENCE A

Document information

Uploaded on
May 26, 2026
Number of pages
43
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$25.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.
Excellentdocsolution Stanford University
View profile
Follow You need to be logged in order to follow users or courses
Sold
19
Member since
1 year
Number of followers
2
Documents
3478
Last sold
20 hours ago
EXELENCE IN EDUCATIOIN

Welcome to my academic support store—your trusted destination for premium homework help and expert tutoring services. I specialize in core subjects including Psychology, Nursing, Human Resource Management, and Mathematics, providing students with high-quality, meticulously crafted academic resources designed to promote excellence. My mission is simple: to deliver scholarly, reliable, and results-driven content that empowers students to achieve outstanding grades with confidence. Every resource I create is carefully researched, well-structured, and tailored to meet academic standards, ensuring clarity, accuracy, and depth. Recognized as one of Stuvia’s BEST GOLD RATED TUTORS, I am committed to maintaining a reputation built on quality, integrity, and student success. Whether you need support with quizzes, exams, assignments, or comprehensive study guides, I prioritize your goals and work diligently to help you excel. Your academic success is my priority—expect excellence, professionalism, and results you can count on.

Read more Read less
0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

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