PrepGo

AP Computer Science A Practice Quiz: Application Program Interface (API) and Libraries

Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026

Test your understanding with short quizzes. This quiz has 9 questions to check your progress.

Question 1 of 9

According to the provided content, what is a library?

All Questions (9)

According to the provided content, what is a library?

A) A collection of classes.

B) A specification that informs a programmer how to use classes.

C) The data related to a specific class.

D) The actions that an instance of a class can perform.

Correct Answer: A

The content explicitly states, 'Libraries are collections of classes.' The other options describe an API, attributes, and behaviors, respectively.

What is the primary function of an Application Programming Interface (API) specification?

A) To store the data and variables for a class.

B) To group multiple classes into a single collection.

C) To define what an instance of a class can do.

D) To inform the programmer how to use the classes within a library.

Correct Answer: D

The text states, 'An application programming interface (API) specification informs the programmer how to use those classes.' Its purpose is to provide documentation and instructions.

In the context of a class, what are 'attributes'?

A) The actions or functions the class can perform.

B) The collection of classes the class belongs to.

C) The data related to the class, which are stored in variables.

D) The documentation explaining how to use the class.

Correct Answer: C

The content defines attributes as 'the data related to the class and are stored in variables.' Option A describes behaviors.

A programmer is using a 'BankAccount' class from a library. The ability to 'withdrawFunds()' would be considered what aspect of the class?

A) An attribute

B) A behavior

C) A library

D) An API

Correct Answer: B

Behaviors refer to what instances of the class can do. 'withdrawFunds()' is an action or something that can be done with a BankAccount instance, so it is a behavior defined by a method.

How does a programmer learn about the specific attributes and behaviors of a class provided in a library?

A) By creating their own classes from scratch.

B) By consulting the documentation found in the API specification.

C) By examining the variables in their own program.

D) By combining multiple libraries into one.

Correct Answer: B

The text explicitly states that 'Documentation found in API specifications and libraries is essential to understanding the attributes and behaviors of a class defined by the API.'

Behaviors are defined by methods, while attributes are stored in what?

A) Other methods

B) APIs

C) Libraries

D) Variables

Correct Answer: D

The content directly links these concepts: 'Attributes refer to the data related to the class and are stored in variables. Behaviors... are defined by methods.'

A programmer needs to store the 'title' and 'author' for a 'Book' object. These pieces of data represent the object's:

A) Behaviors

B) Methods

C) Attributes

D) API

Correct Answer: C

'title' and 'author' are data related to the 'Book' class. According to the definition, data related to a class are its attributes.

Which statement best synthesizes the relationship between the provided terms?

A) An API is a collection of classes, and a library defines their attributes and behaviors.

B) A library is a collection of classes, and an API's documentation explains the attributes (data) and behaviors (methods) of those classes.

C) A class is a collection of libraries, and an API specifies how to use the class.

D) Attributes and behaviors are types of libraries that are explained by an API.

Correct Answer: B

This option correctly identifies that libraries contain classes and that the API documentation is the key to understanding the attributes (data/variables) and behaviors (actions/methods) of those classes.

What term refers to what instances of a class can do or what can be done with them?

A) Attributes

B) Variables

C) Behaviors

D) Libraries

Correct Answer: C

The provided text defines behaviors as 'what instances of the class can do (or what can be done with them) and are defined by methods.' Attributes and variables refer to data.