📖 AP Computer Science A
AP Computer Science A Practice
AP Computer Science A practice questions with explanations
201
Practice questions
3
Difficulty levels
Free
AI tutoring with LISA
📝 Sample Questions
Try these 5 sample questions from our AP Computer Science A collection. Sign up for free to access all 201 questions with AI tutoring.
Medium
The Tile class contains a toString method that creates a String containing the letter and point value of a Tile . The string should be in the following format.
- A. Letter + "letter " + "(point value = " + pointValue + ")";
- B. "Letter " + letter + ("point value = " + pointValue);
- C. Letter + this.letter + " (point value = " + pointValue + ")";
- D. "Letter " + letter + " (point value = " + (String) pointValue + ")";
- E. "Letter " + letter + " (point value = " + pointValue + ")"; ✓
Explanation: 26. (E) The actual letter and its point value must not be in quotes because their values must be printed. Everything else, including the parentheses, must be in quotes. (All text in quotes is printed literally, as is.) Choices A and C fail because they don’t place the opening word, Letter , in quote
Hard
Consider the following instance variable and methods in the same class.
- A. 9
- B. 8
- C. 7 ✓
- D. 4
- E. Compile-time error. No value returned.
Explanation: The max methods shown are overloaded methods (same name but different parameter types). In the given statement, matrix[2] and matrix[3] refer to row 2 and row 3 of the matrix, respectively, each of which is an array of int . max(matrix[2]) is the largest element in row 2 , namely 7 , and max(matrix[
Hard
For binSearch , which of the following assertions will be true following every iteration of the while loop?
- A. key = a[mid] or key is not in a .
- B. a[low] ≤ key ≤ a[high]
- C. low ≤ mid ≤ high
- D. key = a[mid] , or a[low] ≤ key ≤ a[high]
- E. key = a[mid] , or a[low] ≤ key ≤ a[high] , or key is not in array a . ✓
Explanation: 14. (E) When the loop is exited, either key = a[mid] (and mid has been returned) or key has not been found, in which case either a[low] ≤ key ≤ a[high] or key is not in the array. The correct assertion must account for all three possibilities.
Hard
Refer to the following recursive method.
- A. 12 ✓
- B. 10
- C. 8
- D. 6
- E. 4
Explanation: Let mystery(3) be denoted m (3). Picture the execution of the method as follows:
Easy
Consider the following code segment, applied to list , an ArrayList of Integer values.
- A. 2 3 4 2 1 8 ✓
- B. 2 3 4 6 2 2 0 1 8
- C. 2 3 4 0 1 2
- D. 2 3 4 6 1 8
- E. 2 3 3 2
Explanation: Recall that add(index, obj) shifts all elements, starting at index , one unit to the right, then inserts obj at position index . The set(index, obj) method replaces the element in position index with obj . So here is the state of list after each change:
🤖 How LISA Helps You Study AP Computer Science A
Step-by-Step Solutions
Get detailed walkthroughs of every problem. LISA explains each step so you understand the reasoning, not just the answer.
Adaptive Practice
Questions adjust to your skill level using Bayesian Knowledge Tracing. You'll always be challenged at the right level.
Weakness Analysis
LISA identifies your weak areas and builds targeted study plans. Focus your time where it matters most.
Start Practicing AP Computer Science A
Access all 201 questions with free AI tutoring.
Get Started Free