Skip to main content

AP Computer Science Exam Practice Tests - 1208 Verified Questions

Page 1


AP Computer Science Exam Practice Tests

Course Introduction

AP Computer Science introduces students to the foundational concepts of computer science, focusing on problem-solving, algorithm development, and programming using the Java language. Through hands-on programming projects, students learn about object-oriented design, data structures, logic, and software engineering practices. The course fosters critical thinking and computational skills, preparing students for further study in computer science or related fields while also preparing them for the AP Computer Science A exam.

Recommended Textbook

Java Programming 7th Edition by Joyce Farrell

Available Study Resources on Quizplus

17 Chapters

1208 Verified Questions

1208 Flashcards

Source URL: https://quizplus.com/study-set/1207 Page 2

Chapter 1: Creating Java Programs

Available Study Resources on Quizplus for this Chatper

68 Verified Questions

68 Flashcards

Source URL: https://quizplus.com/quiz/23890

Sample Questions

Q1) ____ describes the feature of languages that allows the same word to be interpreted correctly in different situations based on the context.

A) Polymorphism

B) Architecturally neutral

C) Source code

D) Insulation

Answer: A

Q2) ____ is the process the compiler uses to divide your source code into meaningful portions; the message means that the compiler was in the process of analyzing the code when the end of the file was encountered prematurely.

A) Running

B) Debugging

C) Compiling

D) Parsing

Answer: D

Q3) ____________________ comments are a special case of block comments that are used to generate documentation.

Answer: Javadoc

To view all questions and flashcards with answers, click on the resource link above. Page 3

Chapter 2: Using Data

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

Source URL: https://quizplus.com/quiz/23891

Sample Questions

Q1) A(n) ____________________ number contains decimal positions.

Answer: floating-point float double

Q2) ____________________ forces a value of one data type to be used as a value of another type.

Answer: Type casting type casting Casting casting

Q3) You may declare an unlimited number of variables in a statement as long as the variables are ____.

A) the same data type

B) initialized to the same value

C) properly commented

D) floating point numbers

Answer: A

Q4) Write the statement to declare an uninitialized integer value for salesAmt.

Answer: int salesAmt; The statement must end with a semicolon.

Page 4

To view all questions and flashcards with answers, click on the resource link above.

Chapter 3: Using Methods, Classes, and Objects

Available Study Resources on Quizplus for this Chatper

68 Verified Questions

68 Flashcards

Source URL: https://quizplus.com/quiz/23892

Sample Questions

Q1) A(n) ____________________ is a number appended to a field, typically an ID number or account number.

Answer: check-digit

Q2) Describe how you can use multiple arguments in a method.

Answer: You can pass multiple arguments to a method by listing the arguments within the call to the method and separating them with commas. For example, rather than creating a predictRaise() method that adds a 10% raise to every person's salary, you might prefer to create a method to which you can pass two values-the salary to be raised as well as a percentage figure by which to raise it.

Q3) The name of the ____ is always the same as the name of the class whose objects it creates.

A) method

B) constructor

C) argument

D) variable

Answer: B

Q4) To execute a method, you ____________________ it from another method.

Answer: invoke call

To view all questions and flashcards with answers, click on the resource link above. Page 5

Chapter 4: More Object Concepts

Available Study Resources on Quizplus for this Chatper

67 Verified Questions

67 Flashcards

Source URL: https://quizplus.com/quiz/23893

Sample Questions

Q1) The compiler determines which version of a method to call by the method's ____.

A) name

B) signature

C) output

D) constructor

Q2) As long as you do not make any ambiguous method calls, a program that contains a potentially ambiguous situation will execute correctly.

A)True

B)False

Q3) You can use the keyword final with methods or classes.

A)True

B)False

Q4) When an object of one class is a data field within another class, they are related by ____.

A) extension

B) scope

C) composition

D) is-a

Q5) When you pass a(n) ____________________, you pass a memory address.

Page 6

Q6) What is the difference between class variables and instance variables?

To view all questions and flashcards with answers, click on the resource link above.

Chapter 5: Making Decisions

Available Study Resources on Quizplus for this Chatper

70 Verified Questions

70 Flashcards

Source URL: https://quizplus.com/quiz/23894

Sample Questions

Q1) Why would a programmer use an AND operator when using nested if statements?

Q2) Within an if or an else statement, how can you code as many dependent if statements as you need?

Q3) An alternative to using a Boolean expression, such as someVariable == 10, is to store the Boolean expression's value in a Boolean variable.

A)True

B)False

Q4) When you execute an if else statement, only one of the resulting actions takes place depending on the evaluation of the ____ following the if.

A) Boolean expression

B) keyword

C) else statement

D) independent statement

Q5) You are never required to use a switch structure; you can always achieve the same results with nested ____________________ statements.

Q6) ____________________ statements are particularly useful when two conditions must be met before some action is taken.

Q7) Describe how a sequence structure works.

To view all questions and flashcards with answers, click on the resource link above. Page 7

Chapter 6: Looping

Available Study Resources on Quizplus for this Chatper

72 Verified Questions

72 Flashcards

Source URL: https://quizplus.com/quiz/23895

Sample Questions

Q1) What would happen if a semicolon is mistakenly placed at the end of a partial statement of a while loop with a Boolean expression and with an empty body?

Q2) Before entering a loop, the first input, or ____, is retrieved.

A) empty body

B) posttest loop

C) loop body

D) priming read

Q3) Describe how a loop is controlled by a Boolean expression.

Q4) Altering a variable within both a for statement and within the block it controls can produce errors that are difficult to find.

A)True

B)False

Q5) Loop control variables can be evaluated at the start or the end of the loop. Describe both pretest loops and posttest loops. How do do while loops execute?

Q6) Shortcut operators are a programmer's only choice when incrementing or accumulating a variable's value.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 8

Chapter 7: Characters, Strings, and the Stringbuilder

Available Study Resources on Quizplus for this Chatper

73 Verified Questions

73 Flashcards

Source URL: https://quizplus.com/quiz/23896

Sample Questions

Q1) The ____ method allows you to replace all occurrences of some character within a String.

A) substring()

B) toString()

C) replaceCharacter()

D) replace()

Q2) The String class ____ method evaluates the contents of two String objects to determine if they are equivalent.

A) equals()

B) toString()

C) charAt()

D) replace()

Q3) In Java, to ____________________ a String means to break down its separate characters into a numeric format.

Q4) String aName = "Michael"

Using the above statement, write the length() method that will return the length of the aName String. What value will the length() method return when executed?

Q5) What is a wrapper and why would you use it?

Q6) Describe how a reference is used in Java.

To view all questions and flashcards with answers, click on the resource link above. Page 9

Chapter 8: Arrays

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

Source URL: https://quizplus.com/quiz/23897

Sample Questions

Q1) Using just one statement, declare and create an array that will reserve memory locations for 10 scores values that are type double.

Q2) In Java, boolean array elements automatically are assigned the value ____.

A) null

B) '\u0000'

C) true

D) false

Q3) A(n) ____________________ is a named list of data items that all have the same type.

Q4) When using parallel arrays, if one array has many possible matches, it is most efficient to place the less common items first so that they are matched right away.

A)True

B)False

Q5) When you create an array variable, memory space is automatically reserved. A)True

B)False

Q6) Write the statement to declare an array of integers that will hold studentScores.

Q7) What does an array's name represent and what value does it hold when declared?

To view all questions and flashcards with answers, click on the resource link above. Page 10

Chapter 9: Advanced Array Concepts

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

Source URL: https://quizplus.com/quiz/23898

Sample Questions

Q1) Dummy values are a common programming technique used with arrays. Explain the importance of dummy values and how they can be used to ensure that the subscript does not exceed the allowable limit.

Q2) The Arrays class ____________________ method sorts the specified array into ascending order.

Q3) enum Color {RED, GREEN, BLUE} public class EnumOrdinal

{ public static void main(String[] args) {

The above code demonstrates the use of the enum ordinal() method to get the ordinal value of an enum constant. Fill in the shaded lines with println() statements that will get the ordinal of the enumeration constant. Describe the output that will display when the code is executed.

To view all questions and flashcards with answers, click on the resource link above. Page 11

Chapter 10: Introduction to Inheritance

Available Study Resources on Quizplus for this Chatper

70 Verified Questions

70 Flashcards

Source URL: https://quizplus.com/quiz/23899

Sample Questions

Q1) Within a subclass, you can think of the keyword ____ as the opposite of super.

A) sub

B) this

C) protected

D) not

Q2) The class used as a basis for inheritance is the ____ class.

A) child

B) extends

C) base

D) derived

Q3) The methods in a subclass can use all of the data fields and methods that belong to its parent, with one exception: ____ members of the parent class are not accessible within a child class's methods.

A) private

B) public

C) final

D) protected

Q4) What happens when you write your own constructor in Java and what must you pay attention to?

Q5) How is the keyword protected used?

To view all questions and flashcards with answers, click on the resource link above. Page 12

Chapter 11: Advanced Inheritance Concepts

Available Study Resources on Quizplus for this Chatper

70 Verified Questions

70 Flashcards

Source URL: https://quizplus.com/quiz/23900

Sample Questions

Q1) In the Java programming language, a package or class library is often delivered to users as a(n) ____________________ file.

Q2) If Java did not allow you to ____ classes, you would need to create every part of a program from scratch.

A) extend

B) override

C) abstract

D) import

Q3) If you attempt to instantiate an object from an abstract class, you receive an error message from the compiler that you have committed a(n) ____.

A) LogicError

B) InstantiationError

C) SyntaxError

D) ObjectError

Q4) The Object class contains a(n) ____________________ method that takes a single argument, which must be the same type as the type of the invoking object.

Q5) In other programming languages, such as C++, abstract classes are known as ____________________ classes.

To view all questions and flashcards with answers, click on the resource link above. Page 13

Chapter 12: Exception Handling

Available Study Resources on Quizplus for this Chatper

65 Verified Questions

65 Flashcards

Source URL: https://quizplus.com/quiz/23901

Sample Questions

Q1) What advantages does object-oriented exception handling provide?

Q2) To create your own throwable Exception class, you must extend a subclass of Catchable.

A)True

B)False

Q3) When you catch an Exception object, you can call ____________________ to display a list of methods in the call stack so you can determine the location of the statement that caused the exception.

Q4) If you create an object using Java's BigDecimal class, and then perform a division that results in a non-terminating decimal division such as 1/3, but specify that an exact result is needed, a(n) ____________________ is thrown.

Q5) Placing data conversion attempts in a try block allows you to handle potential data conversion errors caused by careless user entry.

A)True

B)False

Q6) What are the elements that make up a try block?

Q7) What is an Exception class? Give an example.

Q8) How is an Error class different from an Exception class?

Q9) When a program contains multiple catch blocks, how are they handled?

To view all questions and flashcards with answers, click on the resource link above. Page 14

Chapter 13: File Input and Output

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

Source URL: https://quizplus.com/quiz/23902

Sample Questions

Q1) Describe and provide an example of the differences between real-time applications and interactive programs.

Q2) You can store data in variables within a program, but this type of storage is temporary.

A)True

B)False

Q3) How can you categorize files by the way they store data?

Q4) You can create a writeable file by using the Files class ____ method.

A) getOutputStream()

B) newOutputStream()

C) newFileOutputStream()

D) fileOutputStream()

Q5) Even if you simply want to display records in order based on their key field, you still need to create a random access file.

A)True

B)False

Q6) Briefly describe the ByteBuffer class.

Q7) Provide an example of batch processing.

Q9) Briefly describe the Path class in Java. Page 15

Q8) A(n) ____________________ object is an avenue for reading and writing a file.

To view all questions and flashcards with answers, click on the resource link above.

Page 16

Chapter 14: Introduction to Swing Components

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

Source URL: https://quizplus.com/quiz/23903

Sample Questions

Q1) An object that is interested in an event is called a source.

A)True

B)False

Q2) You define the text to be displayed in a tool tip by using the setToolTipText() method and passing an appropriate ____ to it.

A) Integer

B) Date

C) String

D) Boolean

Q3) How do you modify whether or not a JTextField can be edited?

Q4) Java provides you with a Font class from which you can create an object that holds typeface and size information.

A)True

B)False

Q5) A(n) ____________________ is the default appearance and behavior of any user interface.

Q6) What are the four JFrame constructors?

Q7) Provide an example of an event-driven program.

To view all questions and flashcards with answers, click on the resource link above. Page 17

Q8) How have user interface components changed since the early versions of Java?

Chapter 15: Advanced Gui Topics

Available Study Resources on Quizplus for this Chatper

69 Verified Questions

69 Flashcards

Source URL: https://quizplus.com/quiz/23904

Sample Questions

Q1) The Color class contains ____ predefined color constants.

A) 7

B) 12

C) 13

D) 15

Q2) Use when you need to add components into a grid of rows and columns; each component is the same size

A)GridBagLayout

B)JScrollPane

C)JPanel

D)glass pane

E)GridLayout

F)action key

G)Color class

H)MouseEvent

I)preferred size

Q3) Describe the difference between an ActionEvent and a MouseEvent.

Q4) How would you arrange columns into equal rows and columns? Provide an example.

Q5) Write the statement to establish a GridLayout with three horizontal rows and six vertical columns in a Container named myGrid.

Page 18

To view all questions and flashcards with answers, click on the resource link above.

Chapter 16: Graphics

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

Source URL: https://quizplus.com/quiz/23905

Sample Questions

Q1) You can instruct a Graphics object to use a font by inserting the font as the argument in a ____ method.

A) setColor()

B) drawString()

C) setCharacters()

D) setFont()

Q2) Both Rectangle2D.Float and Rectangle2D.Double can be created using four arguments representing the x-coordinate, y-coordinate, width, and height.

A)True

B)False

Q3) What parameters does the copyArea() method require?

Q4) Which statement sets the font of a Graphics object named brush to boldFont?

A) Font.setFont = brush

B) setFont = brush(boldFont)

C) brush.setFont(boldFont)

D) Font = setFont(boldFont)

Q5) You can improve the appearance of strings drawn using Graphics objects by using the ____________________ method.

Q6) What are the three arguments the BasicStroke constructor takes?

Page 19

To view all questions and flashcards with answers, click on the resource link above.

Chapter 17: Applets, Images, and Sound

Available Study Resources on Quizplus for this Chatper

72 Verified Questions

72 Flashcards

Source URL: https://quizplus.com/quiz/23906

Sample Questions

Q1) Describe the two methods for running an applet.

Q2) The ___________________ method is always called after the init() and start() methods execute.

Q3) If the JApplet class was not already written, you would have to write more than ____ methods to give your JApplet all the capabilities of the built-in JApplet class.

A) 20

B) 50

C) 200

D) 300

Q4) To compile an applet into bytecode, use the ____ command.

A) appletview

B) viewapp

C) javac

D) java

Q5) Applets can delete, read, or create files on the user's system.

A)True

B)False

Q6) Briefly describe the image formats that Java supports.

Q7) A(n) ___________________ is a likeness of a person or thing.

Page 20

To view all questions and flashcards with answers, click on the resource link above.

Turn static files into dynamic content formats.

Create a flipbook
AP Computer Science Exam Practice Tests - 1208 Verified Questions by Quizplus - Issuu