1/39
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Branching
Flow of control that allows different and separate pieces of code to be executed based on a condition.
Binary decisions
Decisions between two choices e.g. yes/no, true/false, on/off.
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.
Block of code
A piece of code between a pair of opening and closing curly braces.
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.
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.
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.
Identity equality
Whether two objects are the exact same object.
Content equality
Whether two objects contain data/info that matches one another.
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.
toUpperCase() String method
Converts all characters in the String to uppercase.
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.
equalsIgnoreCase() String method
Compares the contents of a string to another string, ignoring capitalization; returns true if the spelling matches regardless.
toLowerCase() String method
Converts all characters in the string to lowercase.
compareToIgnoreCase() String method
Same as compareTo(), but ignores capitalization.
Lexicographically sorted
Words are sorted alphabetically as if they were in a dictionary.
Logical operator
An operator that can be applied to Boolean values or expressions.
&& operator
"And" operator; it evaluates both Boolean conditions and executes the code within the block if both are true.
|| operator
"Or" operator; it evaluates both conditions. If at least one of them is true, it executes the code within the block.
! 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.
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.
Truth tables
Truth tables list every possible outcome based on every possible combination of inputs, usually for compound Boolean expressions.
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.
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.
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.
Repetition
A way to repeat one or more statements.
Loop
A repetitive cycle that starts over again once it finishes one iteration (until a terminating condition is met).
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.
Infinite loop
A loop that never stops due to terminating conditions not being met.
Off-by-one errors
When a program gives you a number that’s exactly 1 value larger or smaller than what you expected.
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.
next() Scanner method
Takes and returns the next token in the file.
hasNext() Scanner method
Checks whether there’s another token that follows; returns true if so.
hasNextLine() Scanner method
Checks whether there’s another line of input for this scanner; returns true if so.
nextLine() Scanner method
Advances the scanner past the current line and returns the skipped input.
Purpose of a for loop
To count the number of iterations by ascending or decrementing a variable until the loop is finished.
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.
Iterative structures for writing to text files
The for and while loops.
close() method for file writing
Important to include to finish writing to a text file.
Datatype for casting a number to a Unicode character