Module 2 (Prelim) Flashcards
2.1 Overview 2.2 Relational and Logical Expressions 2.3 Arithmetic Assignment Operator 2.4 The if and if...else Statements 2.5 Nested if and else…if statements 2.6 switch Statement
allows a program to make a decision based on the truth or falsity of some statement of fact
condition
________ in if structures are formed by using the relational operators and logical operators.
Conditions
________ and ________ operators are binary operators (except !) and yield either true or false boolean value.
- Relational
- logical
Types of relational operators: (6)
==
!=
<
<=
>
>=
Types of logical operators (in order): (3)
!
&&
||
Relational operators are higher than logical operators (&&, ||)
(True or False)
T
Relational operators:
Equality operators (==, !=) are higher than comparison operators (<, >, <=, >=)
F
Unary operators (ex. ! ) has the highest order of precedence
T
Arrange the ff operator types from highest to lowest:
Arithmetic
Unary
Ternary
Relational
Assignment
Bitwise
Logical
Unary (~, !)
Arithmetic (*, /, %, and +, -)
Relational (<, >, <=, >=, and ==, !=)
Bitwise (&, ^, |)
Logical (&& and ||)
Ternary (? and :)
Assignment (=, +=, -= , etc.)
Repeatedly increasing a value by some amount
Accumulating
Java provides shortcuts for incrementing and accumulating such as: (5)
*=
/=
%=
( arithmetic operators + (=) assign operator)
the associativity of ! is from left-to-right
(True or False)
F
right-to-left
In Java, when you want to take an action if a Boolean expression is true, you use an ________ statement.
if
If you want to take an action when a Boolean expression is true but take a different action when the expression is false, you use an ________ statement.
if…else
if and if…else statements can be used to create:
One-way selection
Two-way selection
Multiple selections
if statement one-way selection syntax:
if (expression)
….statement
if and if…else will only apply the first statement below the condition.
(True or False)
T
unless the programmer uses a { } for multiple commands