1/18
Flashcards covering boolean types, comparison and logical operators, if statements (one-way, two-way, multiple alternative), switch statements, conditional operators, and operator precedence/associativity in Java programming.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
boolean Type
A data type in Java that represents a logical value, either true or false, often as the result of a comparison.
Comparison Operators (Relational Operators)
Java operators used to compare two values, such as < (less than),
One-Way if Statement
A control structure in Java that executes a block of statements only if a specified boolean-expression evaluates to true.
Two-Way if Statement (if-else)
A control structure in Java that executes one block of statements if a boolean-expression is true, and a different block if it is false.
Multiple Alternative if Statements
A series of if-else if-else constructs used to evaluate multiple conditions sequentially, where only the statements associated with the first true condition are executed.
Logic Error
An error in programming that causes a program to produce incorrect results, often difficult to find because it does not stop compilation or execution, such as adding a semicolon after an if clause.
Logical Operators
Operators in Java used to combine or modify boolean expressions, including ! (not), && (and), || (or), and ^ (exclusive or).
Logical Negation (!)
A logical operator that reverses the boolean value of an expression, turning true into false and false into true.
Logical Conjunction (&& - AND)
A logical operator that evaluates to true only if both of the boolean expressions it connects are true; otherwise, it is false (short-circuit AND).
Logical Disjunction (|| - OR)
A logical operator that evaluates to true if at least one of the boolean expressions it connects is true; it is false only if both are false (short-circuit OR).
Logical Exclusion (^ - Exclusive OR)
A logical operator that evaluates to true if exactly one of the boolean expressions it connects is true, but not both; otherwise, it is false.
switch Statement
A control structure in Java that allows a program to execute different blocks of code based on the value of a single switch-expression.
switch-expression
The expression within a switch statement that must yield a value of char, byte, short, or int type, determining which case block to execute.
case (in switch statement)
A label within a switch statement that specifies a constant value; if the switch-expression matches this value, the associated statements are executed.
break (in switch statement)
A keyword used at the end of a case block in a switch statement to terminate the execution of the switch statement and prevent fall-through to subsequent cases.
default (in switch statement)
An optional case in a switch statement that specifies actions to be performed if the switch-expression does not match any of the other specified case values.
Conditional Operator (Ternary Operator)
An operator in the form (boolean-expression) ? expression1 : expression2, which evaluates to expression1 if the boolean-expression is true, and expression2 if it is false.
Operator Precedence
A rule that determines the order in which operators in a Java expression are evaluated, such as multiplication before addition or parentheses first.
Operator Associativity
A rule that determines the order of evaluation for operators with the same precedence; most binary operators are left-associative, while assignment operators are right-associative.