AP® Computer Science A glossary

Selection

Also called: decision making, conditional statement

Course: AP® Computer Science A Shows up in: Unit 2: Selection and Iteration

An algorithm building block in which a true or false decision chooses how the execution of the algorithm proceeds.

Appears in the course and exam description (CED): 2.1.A.12.1.A.22.1.A.32.3.A.1

Selection is one of the three building blocks of algorithms, with sequencing and repetition. In Java, selection statements (if, if-else, if-else-if) change the sequential execution of statements.

int temperature = 31;
if (temperature > 25) {
    System.out.println("Wear shorts");
}

Output:

Wear shorts
Learn it properly, with a checkpoint 2.1 Algorithms with Selection and Repetition

Related terms

Was this page helpful?

No names are ever shown, and every public comment is checked by us first. Please do not include personal details. To get a reply, email [email protected].

↑ Top

Enlarged view of the selected figure