

AP Computer Science A Exam Practice Tests
Course Introduction
AP Computer Science A is an introductory college-level course that focuses on object-oriented programming using the Java language. Students learn fundamental concepts such as variables, data types, control structures, algorithms, and object-oriented design principles. Throughout the course, emphasis is placed on problem-solving, logical thinking, and debugging techniques. By working on programming projects and practice exercises, students develop their abilities to write, analyze, and implement code effectively. The course also prepares students for the AP Computer Science A exam, which assesses their understanding of core programming concepts and their ability to apply them in real-world scenarios.
Recommended Textbook
Starting Out with Java From Control Structures through Data Structures 2nd Edition by Tony Gaddis
Available Study Resources on Quizplus
22 Chapters
981 Verified Questions
981 Flashcards
Source URL: https://quizplus.com/study-set/3640

Page 2

Chapter 1: Introduction to Computers and Java
Available Study Resources on Quizplus for this Chatper
42 Verified Questions
42 Flashcards
Source URL: https://quizplus.com/quiz/72352
Sample Questions
Q1) Byte code instructions are:
A) Another name for source code
B) Syntax errors
C) Machine code instructions
D) Read and interpreted by the JVM
Answer: D
Q2) A runtime error is usually the result of:
A) A logical error
B) A syntax error
C) A compilation error
D) Bad data
Answer: A
Q3) Variables are:
A) Symbolic names made up by the programmer that represents locations in the computer's RAM
B) Reserved words
C) Symbolic names made up by the programmer whose values cannot be changed
D) Operators that perform operations on one or more operands
Answer: A
To view all questions and flashcards with answers, click on the resource link above.
Page 3

Chapter 2: Java Fundamentals
Available Study Resources on Quizplus for this Chatper
53 Verified Questions
53 Flashcards
Source URL: https://quizplus.com/quiz/72353
Sample Questions
Q1) What would be displayed as a result of the following code? int x = 578; System.out.print("There are " + X + 5 + " \ n" + "hens in the hen house.");
A) There are 583 hens in the hen house.
B) There are 5785 hens in the hen house.
C) There are x5 \ nhens in the hen house.
D) There are 5785 Hens in the hen house.
Answer: D
Q2) Although the dollar sign is a legal identifier character,you should not use it because it is normally used for special purposes.
A)True
B)False
Answer: True
Q3) In Java the variable named one is the same as the variable named One. A)True
B)False
Answer: False
To view all questions and flashcards with answers, click on the resource link above.
Page 4

Chapter 3: Decision Structures
Available Study Resources on Quizplus for this Chatper
52 Verified Questions
52 Flashcards
Source URL: https://quizplus.com/quiz/72354
Sample Questions
Q1) What would be the value of discountRate after the following statements are executed? double discountRate = 0.0;
Int purchase = 100; If (purchase > 1000)
DiscountRate = .05; Else if (purchase > 750)
DiscountRate = .03; Else if (purchase > 500)
DiscountRate = .01;
A) .05
B) .03
C) .01
D) 0.0
Answer: D
Q2) Because the || operator performs short-circuit evaluation,your boolean expression will generally be evaluated faster if the subexpression that is most likely to be true is on the left.
A)True
B)False Answer: True
To view all questions and flashcards with answers, click on the resource link above.
Page 5

Chapter 4: Loops and Files
Available Study Resources on Quizplus for this Chatper
48 Verified Questions
48 Flashcards
Source URL: https://quizplus.com/quiz/72355
Sample Questions
Q1) This type of loop is ideal in situations where the exact number of iterations is known.
A) while loop
B) do-while loop
C) for loop
D) if statement
Q2) A file must always be opened before using it and closed when the program is finished using it.
A)True
B)False
Q3) Which of the following will open a file named MyFile.txt and allow you to read data from it?
A) File file = new File("MyFile.txt");
B) Scanner inputFile = new Scanner("MyFile.txt");
C) File file = new File("MyFile.txt");
Scanner inputFile = new Scanner(file);
D) PrintWriter inputFile = new PrintWriter("MyFile.txt");
Q4) The do-while loop must be terminated with a semicolon.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 6

Chapter 5: Methods
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/72356
Sample Questions
Q1) Any method that calls a method with a throws clause in its header must either handle the potential exception or have the same throws clause.
A)True
B)False
Q2) No statement outside the method in which a parameter variable is declared can access the parameter by its name.
A)True
B)False
Q3) The expression in a return statement can be any expression that has a value.
A)True
B)False
Q4) Local variables
A) are hidden from other methods
B) may have the same name as local variables in other methods
C) lose the values stored in them between calls to the method in which the variable is declared
D) All of the above
To view all questions and flashcards with answers, click on the resource link above.

Chapter 6: A First Look at Classes
Available Study Resources on Quizplus for this Chatper
49 Verified Questions
49 Flashcards
Source URL: https://quizplus.com/quiz/72357
Sample Questions
Q1) The java.lang package is automatically imported into all Java programs.
A)True
B)False
Q2) When a local variable in an instance method has the same name as an instance field,the instance field hides the local variable.
A)True
B)False
Q3) Instance methods do not have the key word static in their headers.
A)True
B)False
Q4) A constructor is a method that A) returns an object of the class.
B) never receives any arguments.
C) with the name ClassName.constructor.
D) performs initialization or setup operations.
Q5) After the header,the body of the method appears inside a set of A) brackets,[]
B) paretheses, ()
C) braces,{}
D) double quotes,""
To view all questions and flashcards with answers, click on the resource link above. Page 8

Chapter 7: A First Look at Gui Applications
Available Study Resources on Quizplus for this Chatper
49 Verified Questions
49 Flashcards
Source URL: https://quizplus.com/quiz/72358
Sample Questions
Q1) The System.exit method will end the application.
A)True
B)False
Q2) What does the following statement do? addButton.addActionListener(new AddButtonListener());
A) Creates an AddButtonListener object
B) Registers the addButton object as an ActionListener with the AddButtonListener object
C) Creates an AddButtonListener object and registers the AddButtonListener object with the addButton
D) Nothing,the statement is invalid
Q3) The minimize button,maximize button,and close button on a window are sometimes referred to as
A) operations buttons
B) sizing buttons
C) decorations
D) display buttons
Q4) The FlowLayout manager does not allow the programmer to align components.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 9

Chapter 8: Arrays and the Arraylist Class
Available Study Resources on Quizplus for this Chatper
52 Verified Questions
52 Flashcards
Source URL: https://quizplus.com/quiz/72359
Sample Questions
Q1) What would be the results of the following code? int[] x = { 55,33,88,22,99, 11,44,66,77 };
Int a = 10;
If(x[2] > x[5])
A = 5; Else
A = 8;
A) a = 5
B) a = 8
C) a = 10
D) This is a compilation error,you cannot compare array elements
Q2) Any items typed on the command-line,separated by space,after the name of the class are considered to be one or more arguments that are to be passed into the main method.
A)True
B)False
Q3) Java does not limit the number of dimensions that an array may have. A)True
B)False
To view all questions and flashcards with answers, click on the resource link above.
Page 10

Chapter 9: A Second Look at Classes and Objects
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/72360
Sample Questions
Q1) Assuming the following declaration exists: enum Tree { OAK,MAPLE,PINE } What will the following code display? System.out.println(Tree.OAK);
A) Tree.OAK
B) 0
C) 1
D) OAK
E) Nothing.This statement will cause an error.
Q2) An instance of a class does not have to exist in order for values to be stored in a class's static fields.
A)True
B)False
Q3) Enum constants have a toString method.
A)True
B)False
Q4) An enumerated data type is actually a special type of class.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above.
11

Chapter 10: Text Processing and More About Wrapper
Classes
Available Study Resources on Quizplus for this Chatper
49 Verified Questions
49 Flashcards
Source URL: https://quizplus.com/quiz/72361
Sample Questions
Q1) What would be the results of executing the following code? StringBuilder str = new StringBuilder("Little Jack Horner ");
Str)append("sat on the ");
Str)append("corner");
A) The program would crash.
B) str would reference "Little Jack Horner ".
C) str would reference "Little Jac Horner sat on the ".
D) str would reference "Little Jack Horner sat on the corner".
Q2) To convert the int variable,number to a string,use the following statement.
A) String str = Integer.toString(number);
B) String str = integer.toString(number);
C) String str = integer(number);
D) String str = number.Integer.toString(str);
Q3) You cannot assign a value to a wrapper class object.
A)True
B)False
Q4) If a non-letter argument is passed to the toLowerCase or toUpperCase method,the boolean value false is returned.
A)True B)False
To view all questions and flashcards with answers, click on the resource link above. Page 12

Chapter 11: Inheritance
Available Study Resources on Quizplus for this Chatper
49 Verified Questions
49 Flashcards
Source URL: https://quizplus.com/quiz/72362
Sample Questions
Q1) In the following statement,which is the subclass? public class ClassA extends ClassB implements ClassC
A) ClassA
B) ClassB
C) ClassC
D) Cannot tell
Q2) All methods in an abstract class must also be declared abstract.
A)True
B)False
Q3) If a superclass does not have a default constructor or a no-arg constructor,
A) then a class that inherits from it,must initialize the superclass values.
B) then a class that inherits from it,must call one of the constructors that the superclass does have.
C) then a class that inherits from it,does not inherit the data member fields from the superclass.
D) then a class that inherits from it,must contain the default constructor for the superclass.
Q4) It is not possible for a superclass to call a subclass's method.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 13
Chapter 12: Exceptions and Advanced File Io
Available Study Resources on Quizplus for this Chatper
46 Verified Questions
46 Flashcards
Source URL: https://quizplus.com/quiz/72363
Sample Questions
Q1) Why does the following code cause a compiler error? try
{ Number = Integer.parseInt(str);
}
Catch (IllegalArgumentException e)
{ System.out.println("Bad number format.");
}
Catch (NumberFormatException e)
{ System.out.println(str + " is not a number.");
}
A) Because you can have only one catch clause in a try statement.
B) Because NumberFormatException inherits from IllegalArgumentException.The code should handle NumberFormatException before IllegalArgumentException.
C) Because the Integer.parseInt method does not throw a NumberFormatException.
D) Because the Integer.parseInt method does not throw an IllegalArgumentException.
To view all questions and flashcards with answers, click on the resource link above.

14

Chapter 13: Advanced Gui Applications
Available Study Resources on Quizplus for this Chatper
46 Verified Questions
46 Flashcards
Source URL: https://quizplus.com/quiz/72364
Sample Questions
Q1) A mnemonic is
A) A single key on the keyboard that you press to quickly access a component such as a button.
B) A key on the keyboard that you press in combination with the SHIFT key to quickly access a component such as a button.
C) A key on the keyboard that you press in combination with the ALT key to quickly access a component such as a button.
D) A key on the keyboard that you press in combination with the CTRL key to quickly access a component such as a button.
Q2) The following statement textList.setSelectionMode( ListSelectModel.SINGLE_INTERVAL_SELECTION);
A) sets the textList component to single selection mode.
B) sets the textList component to ListSelectModel.
C) sets the textList component to single interval selection mode.
D) sets the value of textList to SINGLE_INTERVAL_SELECTION.
Q3) A label's preferred size is determined only by calling the setPreferredSize method.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above.
15

Chapter 14: Applets and More
Available Study Resources on Quizplus for this Chatper
39 Verified Questions
39 Flashcards
Source URL: https://quizplus.com/quiz/72365
Sample Questions
Q1) If a frame component is 300 pixels wide and 200 pixels high,the upper,right-hand corner has (X,Y)coordinates of
A) (0,0)
B) (300,0)
C) (200,300)
D) (299,0)
Q2) Certain restrictions are placed on applets.If an applet attempts to violate one of these restrictions,
A) the program has a fatal error.
B) it will display a window stating that it has violated the restriction.
C) an exception is thrown.
D) it automatically notifies the Web server of the violation.
Q3) Whenever you need a component of any type to be painted,call the paint method.
A)True
B)False
Q4) Which of the following sound file formats does Java not support?
A) .wav
B) .au
C) .mid
D) Java supports all of the above
To view all questions and flashcards with answers, click on the resource link above. Page 16

Chapter 15: Recursion
Available Study Resources on Quizplus for this Chatper
34 Verified Questions
34 Flashcards
Source URL: https://quizplus.com/quiz/72366
Sample Questions
Q1) Look at the following method. public static int test2(int x,int y)
{ If ( x < y)
{ Return -5; } Else { Return (test2(x - y,y + 5)+ 6); } }
What is the depth of test2(18,5)?
A) 0
B) 1
C) 2
D) 3
Q2) A problem can be solved recursively if it can be broken down into successive smaller problems that are identical to the overall problem.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above.
Page 17

Chapter 16: Sorting, Searching, and Algorithm Analysis
Available Study Resources on Quizplus for this Chatper
46 Verified Questions
46 Flashcards
Source URL: https://quizplus.com/quiz/72367
Sample Questions
Q1) For a computational problem,the input size
A) is the number of times the program requests input from the user
B) is the number of loop iterations required to read the input
C) is the amount of memory needed to store the input
D) None of the above
Q2) Sequential Search is in the complexity class
A) O(1)
B) O(log n.
C) O(n.
D) O(n log n.
Q3) The worst case complexity function is a good measure to use when
A) the load on the system is heaviest
B) we want a guarantee on the performance of an algorithm
C) the best case complexity would lead to incorrect results
D) we want to create an efficient algorithm
Q4) To compare String objects for the purpose of sorting,a programmer should
A) use the comparison operator <
B) use the comparison operator < =
C) use the compareTo method of the Comparable interface
D) use the relational operator < to compare references to the String objects
Page 18
To view all questions and flashcards with answers, click on the resource link above.

Chapter 17: Generics
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/72368
Sample Questions
Q1) Comparable< T > is
A) a generic class that you can to instantiate objects that can be compared
B) is a method defined in the Java class libraries that is used to compare objects of generic type
C) is a library module that is useful in implementing generics
D) is an interface defined in the Java class libraries
Q2) The notation < E implements Comparable< E > >
A) will be rejected by the Compiler as an error
B) declares a generic type that implements the Comparable interface
C) is used when there is a recursive definition of the generic type E
D) None of the above
Q3) When a generic method is called,
A) the programmer must explicitly specify the actual types to use for the type parameters
B) the compiler determines the actual types to use for the type parameters from the context
C) the compiler uses information explicitly specified by the programmer,if available;otherwise,the type defaults to Object
D) None of the above
To view all questions and flashcards with answers, click on the resource link above.
Page 19

Chapter 18: Collections
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/72369
Sample Questions
Q1) Comparable
A) specifies a single method,compareTo
B) specifies three methods,compareTo,compare,and equals
C) specifies two methods,compare and equals
D) specifies two methods,compare and compareTo
Q2) The three major categories of Java collections are
A) lists,sets,and maps
B) hash lists,hash tables,and sets
C) sets,collections,and maps
D) tree sets,list sets,and hash maps
Q3) A collision occurs when
A) objects whose class types are not related through inheritance have the same hashcode
B) objects instantiated from different generic types have the same hashcode
C) objects whose class types are not related through inheritance have hashcodes one of which divides the other
D) objects whose values are not equal have the same hash code
To view all questions and flashcards with answers, click on the resource link above. Page 20

Chapter 19: Array-Based Lists
Available Study Resources on Quizplus for this Chatper
20 Verified Questions
20 Flashcards
Source URL: https://quizplus.com/quiz/72370
Sample Questions
Q1) An ArrayList is so called because
A) you can use array subscript notation to work with the ArrayList
B) it is implemented as a class that uses an internal array to hold the elements of the list
C) you can pass it as a parameter to any method that expects an array
D) All of the above
Q2) The E get(int index)method of the List interface should throw an exception if
A) the index passed to it is negative
B) the index passed to it nonnegative
C) the index passed to it is negative or greater or equal to the size of the list
D) the index passed to is negative or greater than the size of the list
Q3) The size of an array-based list such as ArrayList
A) is the number of bytes of memory that the list can hold
B) is the number of elements that are currently stored in the list
C) is the length of its internal array
D) None of the above
Q4) What is the difference between the Iterator and Iterable interfaces? How would you use these two interfaces if you had to write a collection class?
To view all questions and flashcards with answers, click on the resource link above. Page 21
Chapter 20: Linked Lists
Available Study Resources on Quizplus for this Chatper
36 Verified Questions
36 Flashcards
Source URL: https://quizplus.com/quiz/72371
Sample Questions
Q1) A linked list class uses a Node class with successor reference next and field element to store values.It uses a reference first to point to the first node of the list.Code to print all elements stored in the list can be written as
A) System.out.print(first);
B) Node p = first; While (p != null.
{ System.out.println(p.element.; P = p.next;
C) Node p = first; While (p != null. System.out.println(p.next.;
D) Node p = first; For (p!= null.
{ System.out.println(p.element.; P++; } To view all questions and flashcards with answers, click on the resource link above.

22
Chapter 21: Stacks and Queues
Available Study Resources on Quizplus for this Chatper
36 Verified Questions
36 Flashcards
Source URL: https://quizplus.com/quiz/72372
Sample Questions
Q1) The JCF Stack class is used to instantiate a stack: Stack< Integer > intStack = new Stack< Integer >();
The statements
Int k = 77;
IntStack.push(k*k);
Use the primitive type int instead of the wrapper type Integer.These statements
A) cause a compile time error
B) compile and execute correctly
C) cause a ClassCastException
D) None of the above
Q2) In a list implementation of a queue,the end of the list at which elements are added is called
A) the front of the queue
B) the rear of the queue
C) the head of the queue
D) the bottom of the queue
To view all questions and flashcards with answers, click on the resource link above.

23

Chapter 22: Binary Trees, Avl Trees, and Priority Queues
Available Study Resources on Quizplus for this Chatper
45 Verified Questions
45 Flashcards
Source URL: https://quizplus.com/quiz/72373
Sample Questions
Q1) A node in a binary tree that has no children is called A) a leaf
B) a single node
C) barren
D) a twig
Q2) Consider the operation of deleting the root of a binary search tree.If the root is a leaf,then
A) the method doing the deletion should throw an exception
B) the root should be replaced with a dummy place-holder node
C) the reference to the root of the tree should be set to null
D) the element stored in the root node should be replaced with null,or with 0.
Q3) To find the minimum element stored in a heap
A) you should start at the root,and then keep passing from each node to its left child until you come to a node with no left child
B) you should start at the root,and then keep passing from each node to its right child until you come to a node with no right child
C) you should look at the root of the binary tree
D) you need to examine every node,and then pick the one with the least value
To view all questions and flashcards with answers, click on the resource link above. Page 24