AP CSP 3.14 Exercise 2: Libraries Applied Challenge

Big Idea 3: Algorithms and Programming · Topic 3.14 · Exercise 2

Libraries: Applied Challenge

Six decisions about using existing code, and about what you still owe the reader when you do.

How this one is different

Using a library is normal and expected. Knowing what it does not free you from, including documentation and attribution, is the tested part.

Applied Practice

6 questions · scenario driven · every answer is recorded for your teacher

Question 1 of 6Apply
A developer needs to sort a list and a well tested sort already exists in a library.
What is the strongest reason to use it rather than write one?
Correct. Reuse buys both the implementation and the accumulated testing, which is the part that is expensive to reproduce.
Incorrect. Writing your own is permitted, and is sometimes the right choice.
Incorrect. Memory use varies and is not a general guarantee.
Incorrect. A library is often faster but not always, and speed is not the primary argument.
Question 2 of 6Analyze
What does an API provide to a developer?
Incorrect. No interface guarantees correctness.
Incorrect. Usage rights come from a license, which is a separate document.
Incorrect. An API is the interface, and the source may not be available at all.
Correct. An API is the contract that lets a developer use code as an abstraction, which is the same relationship a caller has with any procedure.
Question 3 of 6Evaluate
A student copies a procedure from an online forum into their Create Task submission without noting where it came from.
What is the problem?
Incorrect. It may run perfectly, which is exactly why the attribution rule matters.
Incorrect. Borrowed code may be perfectly correct. Correctness is not the issue.
Correct. Using existing code is allowed and expected, but it must be attributed, and it cannot satisfy a requirement that asks for the student's own work.
Incorrect. Using outside code with attribution is explicitly permitted.
Question 4 of 6Transfer
A library procedure returns an unexpected result for certain inputs.
What is the correct first step?
Incorrect. Rewriting is an enormous response to a misunderstanding that has not been confirmed.
Correct. Documentation defines the contract. Most surprises turn out to be a caller expecting something the contract never promised.
Incorrect. One surprise is not a reason to abandon reuse.
Incorrect. Reporting a defect before checking the specification frequently reports the caller's own mistake.
Question 5 of 6Apply
Which best describes how libraries relate to abstraction?
Correct. The interface is the abstraction, and it is what lets a developer use functionality whose implementation they never see.
Incorrect. They are directly related, since a library exists to hide implementation behind an interface.
Incorrect. Libraries support abstraction rather than obstructing it.
Incorrect. A library is an application of abstraction, not a replacement for it.
Question 6 of 6Analyze
Two libraries both provide a procedure named format.
What problem can this create, and what generally prevents it?
Incorrect. Libraries occupy separate files and do not overwrite one another.
Incorrect. Relative speed has nothing to do with the shared name.
Incorrect. Most environments resolve this, and it is a resolvable ambiguity rather than a hard failure.
Correct. Two identical names in one namespace makes a call ambiguous, and qualifying the name with its library is the standard resolution.

Where to go next

Get in Touch

Whether you're a student, parent, or teacher — I'd love to hear from you.

Just want free AP CS resources?

Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]