AP Computer Science A Flashcards: Documentation with Comments
Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026
Review key ideas with interactive flashcards. This set includes 10 cards to help you master important concepts.
How does a compiler or interpreter handle comments when a program is run?
Comments are ignored by the compiler and are not executed when the program is run.
Card 1 of 10
All Flashcards (10)
How does a compiler or interpreter handle comments when a program is run?
Comments are ignored by the compiler and are not executed when the program is run.
What kind of outcomes do postconditions typically describe?
Postconditions describe outcomes such as what is being returned by the method or the current value of an object's attributes after execution.
A method's documentation states its precondition is that an input list must not be empty. What must be true before you call this method?
Before calling the method, you must ensure that the list you are passing as an argument contains at least one element.
Who are the intended readers of code comments?
Comments are written for both the original programmer and other programmers to understand the code and its functionality.
A method's postcondition is that an object's `isSorted` attribute is set to `true`. What can you assume after the method finishes running?
You can assume that after the method executes, the `isSorted` attribute of the object will have the value `true`.
What is the primary purpose of comments in code?
The primary purpose of comments is to describe the functionality and use of code for human readers.
What is a postcondition in the context of a method?
A postcondition is a condition that must always be true after the execution of a method, describing its outcome.
What is a precondition in the context of a method?
A precondition is a condition that must be true just prior to the execution of a method in order for it to behave as expected.
Contrast the timing of a precondition with a postcondition relative to a method's execution.
A precondition must be true *before* a method is executed, while a postcondition must be true *after* the method has finished executing.
Is a method expected to verify that its preconditions are met before executing?
No, there is no expectation that a method will check to ensure its own preconditions are satisfied.