COP2253 Zybooks Chapter Three Flashcards
branch
a program path taken only if an expression’s value is true
if-else structure
two branches, one taken if an expression is true, else the other branch is taken (else may be ommitted)
if statement
executes a group of statements if an expression is true
braces
{}
brackets
[]
equality operator
==
nested if-else
the branch of one if-else statement contains another if-else statement
Boolean
a type that has just two values, true or false
relational operator
checks how one operand’s value relates to another (, <=, >=)
logical operator
treats operands as being true or false, and evaluates to true or false (include AND, OR, NOT)
logical AND
&&
logical OR
||
logical NOT
!
switch statement
executes the first case whose constant expression matches the value of the switch expression, executes the case’s statements, and then jumps to the end: break statement (if there is no matching case, then default statements are executed)
equals method (equalsIgnoreCase)
used to compare strings, returns true if strings are equal
index (starting at 0)
the position number of each character in a string
charAt(x)
determines the character at index x of a string
.length()
returns the length of a string
exception
a detected runtime error that commonly prints an error message and terminates the program
strings are immutable meaning:
they cannot be changed
conditional expression
has the form
condition ? exprWhenTrue : exprWhenFalse
short circuit evaluation
skips evaluating later operands if the result of the logical operator can already be determined