FLVS AP Computer Science A - Module 3: Selection and Repetition

0.0(0)
studied byStudied by 0 people
0.0(0)
linked notesView linked note
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/39

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

40 Terms

1
New cards

Branching

Flow of control that allows different and separate pieces of code to be executed based on a condition.

2
New cards

Binary decisions

Decisions between two choices e.g. yes/no, true/false, on/off.

3
New cards

Semicolon at the end of an IF statement

The program won’t run as intended as a semicolon indicates the end of an if block and tells the program to move on.

4
New cards

Block of code

A piece of code between a pair of opening and closing curly braces.

5
New cards

Difference between an IF and an IF-ELSE statement

An if statement only cares about whether the condition inside is true, and moves on if it’s false. An if-else statement checks for the first condition, and then checks for another condition if the first condition is false.

6
New cards

Difference between an IF-ELSE and an IF-ELSE-IF statement

An IF-ELSE statement checks for one condition, while an IF-ELSE-IF checks for at least two conditions.

7
New cards

Nested IF statements

Nested IF statements consist of multiple if statements, usually in the form of embedding at least one IF/IF-ELSE/IF-ELSE-IF statement inside another IF-ELSE/IF/IF-ELSE-IF statement.

8
New cards

Identity equality

Whether two objects are the exact same object.

9
New cards

Content equality

Whether two objects contain data/info that matches one another.

10
New cards

equals() method

Checks for the content equality of a string object with a specified string; it compares the value/contents of a string to see whether it’s identical to an existing string.

11
New cards

toUpperCase() String method

Converts all characters in the String to uppercase.

12
New cards

compareTo() String method

Compares two strings to see which one would go first alphabetically. A negative integer is returned if the first string is ordered alphabetically before the second, and a positive integer if the second comes first. A result of 0 indicates that the contents of both strings are exactly the same.

13
New cards

equalsIgnoreCase() String method

Compares the contents of a string to another string, ignoring capitalization; returns true if the spelling matches regardless.

14
New cards

toLowerCase() String method

Converts all characters in the string to lowercase.

15
New cards

compareToIgnoreCase() String method

Same as compareTo(), but ignores capitalization.

16
New cards

Lexicographically sorted

Words are sorted alphabetically as if they were in a dictionary.

17
New cards

Logical operator

An operator that can be applied to Boolean values or expressions.

18
New cards

&& operator

"And" operator; it evaluates both Boolean conditions and executes the code within the block if both are true.

19
New cards

|| operator

"Or" operator; it evaluates both conditions. If at least one of them is true, it executes the code within the block.

20
New cards

! operator

It negates the outcome of a Boolean expression; it checks to see whether a certain outcome has NOT been achieved and returns true if so.

21
New cards

Negation

Using the logical operator ! (Not) to reverse the evaluation of a Boolean expression and ensure that a specified condition doesn’t happen before returning true.

22
New cards

Truth tables

Truth tables list every possible outcome based on every possible combination of inputs, usually for compound Boolean expressions.

23
New cards

Short-circuit evaluation

Short-circuit evaluation occurs when only one part of an expression is evaluated to decide whether the entire expression should output true or false.

24
New cards

De Morgan’s First Law

!(A && B) is the same as !A || !B; if both A & B are false, you will get the same output as having either A or B be false.

25
New cards

De Morgan’s Second Law

!(A || B) is the same as !A && !B; if either A or B are false, you will get the same output as having both A & B be false.

26
New cards

Repetition

A way to repeat one or more statements.

27
New cards

Loop

A repetitive cycle that starts over again once it finishes one iteration (until a terminating condition is met).

28
New cards

How a while loop works

If a specified condition hasn’t been met, it executes the block of code inside, then checks the condition again. Only if the condition has been met will the loop stop.

29
New cards

Infinite loop

A loop that never stops due to terminating conditions not being met.

30
New cards

Off-by-one errors

When a program gives you a number that’s exactly 1 value larger or smaller than what you expected.

31
New cards

IOException reasons

A file isn't found (e.g. you specified the wrong address or deleted it); Permission issues (whoever created the original file isn't allowing others to make changes to it); Input/output errors on the device storing the file.

32
New cards

next() Scanner method

Takes and returns the next token in the file.

33
New cards

hasNext() Scanner method

Checks whether there’s another token that follows; returns true if so.

34
New cards

hasNextLine() Scanner method

Checks whether there’s another line of input for this scanner; returns true if so.

35
New cards

nextLine() Scanner method

Advances the scanner past the current line and returns the skipped input.

36
New cards

Purpose of a for loop

To count the number of iterations by ascending or decrementing a variable until the loop is finished.

37
New cards

Logic sequence in nested loops

The innermost loop is carried out first before moving to the loop that directly surrounds it. After the innermost loop finishes, the program moves on to the second innermost loop, and the cycle continues.

38
New cards

Iterative structures for writing to text files

The for and while loops.

39
New cards

close() method for file writing

Important to include to finish writing to a text file.

40
New cards

Datatype for casting a number to a Unicode character