Libraries FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

Docs: power(base, exp) returns base raised to exp for nonnegative integer exp. (a) Write the call for 2^5. (b) Trace the returned value. (c) Explain why power(2) alone does not match the documentation.

Question 2 of 5

A media library documents playTone(freq, ms) to play a tone of frequency freq for ms milliseconds. (a) Write a call that plays 440 for 500 ms. (b) Explain one mistake in playTone(500, 440) relative to the documentation. (c) State why documentation is part of an API.

Question 3 of 5

API excerpt:

Procedure Parameters Returns
join(parts, sep) list of strings; separator string one string with parts separated by sep
split(text, sep) text string; separator string list of pieces

(a) Write a call that joins ["red", "green", "blue"] with separator ",". (b) Predict the return value. (c) Explain how choosing join from the library avoids rewriting concatenation loops.

Question 4 of 5

A student writes five near-copies of a date-formatting block. A library already offers formatDate(y, m, d). (a) Describe how to replace the copies using the library. (b) Give one maintenance benefit. (c) List the three pieces of information documentation must provide before the calls are written.

Question 5 of 5

Docs: endsWith(s, suffix) returns true when s ends with suffix. (a) Write a call that checks whether "notes.txt" ends with ".txt". (b) State the expected return. (c) Explain why endsWith("notes.txt") is not a valid match to the documentation.