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 (44 cards)

1
Q

allows a program to make a decision based on the truth or falsity of some statement of fact

A

condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

________ in if structures are formed by using the relational operators and logical operators.

A

Conditions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

________ and ________ operators are binary operators (except !) and yield either true or false boolean value.

A
  • Relational
  • logical
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Types of relational operators: (6)

A

==
!=
<
<=
>
>=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Types of logical operators (in order): (3)

A

!
&&
||

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Relational operators are higher than logical operators (&&, ||)
(True or False)

A

T

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Relational operators:
Equality operators (==, !=) are higher than comparison operators (<, >, <=, >=)

A

F

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Unary operators (ex. ! ) has the highest order of precedence

A

T

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Arrange the ff operator types from highest to lowest:

Arithmetic
Unary
Ternary
Relational
Assignment
Bitwise
Logical

A

Unary (~, !)
Arithmetic (*, /, %, and +, -)
Relational (<, >, <=, >=, and ==, !=)
Bitwise (&, ^, |)
Logical (&& and ||)
Ternary (? and :)
Assignment (=, +=, -= , etc.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Repeatedly increasing a value by some amount

A

Accumulating

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Java provides shortcuts for incrementing and accumulating such as: (5)

A

*=
/=
%=

( arithmetic operators + (=) assign operator)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

the associativity of ! is from left-to-right
(True or False)

A

F

right-to-left

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In Java, when you want to take an action if a Boolean expression is true, you use an ________ statement.

A

if

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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.

A

if…else

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

if and if…else statements can be used to create:

A

One-way selection
Two-way selection
Multiple selections

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

if statement one-way selection syntax:

A

if (expression)
….statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

if and if…else will only apply the first statement below the condition.
(True or False)

A

T

unless the programmer uses a { } for multiple commands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

if…else statement w/ multiple statements/compound statements syntax:

A

if (expression)
{
….statement1
….statement2
}
else
{
….statement1
….statement2
}

19
Q

if…else statement two-way selection syntax:

A

if (expression)
….statement1
else
….statement2

20
Q

There are statements in which an if structure is contained inside another if structure

21
Q

Two conditions must be met before some action is taken

22
Q

Uses the else if statement to specify a new condition if the first condition is false

A

Nested else…if

23
Q

Nested if syntax:

A

if (condition1)
….if (condition2)
……..statement1;

24
Q

Nested else…if syntax:

A

if (condition1)
….statement1;
else if (condition2)
….statement2;
else if (condition3)
….statement3;
else
….statement n;

25
_________ operator takes 3 arguments
ternary
26
Ternary operator syntax:
expression1 ? expression2 : expression3 (this means that If expression1 is true, the result of the conditional expression is expression2. Otherwise, the result is expression3)
27
An alternative to a series of nested if statements
Switch statements
28
Test a single variable against a series of exact integer, character, or string values
Switch statements
29
Switch statement keywords: (4)
- switch - case - break - default
30
Starts the switch structure followed by a test expression enclosed in parentheses
switch
31
Followed by one of the possible values for the test expression and a colon. Braces are not needed to turn multiple statements into a single compound statement
case
32
In a switch statement when a case value is matched, all statements after it execute until a ______ is encountered
break
33
The break statement may or may not appear after each statement in switch statements (True or False)
T
34
Switch statement: Optionally ________ is used prior to any action that should occur if the test variable does not match any case
default
35
There are two types of algorithm:
Pseudocode Flowchart
36
Plan a program’s logic by writing plain English statements
Pseudocode
37
- Steps in diagram form - A series of shapes connected by arrows
Flowchart
38
The six (6) basic flowcharting symbols are:
- Terminator ⬭ - Input/Output ▱ - Process ▭ - Decision ◇ - Connector ◯ - Flowline / arrows →
39
used to represent the start and end of a flowchart
Terminator ⬭
40
used for input and output decisions in a flowchart
Input/Output ▱
41
used for arithmetic and data manipulation operations in a flowchart
Process ▭
42
used for logic of comparison operations in a flowchart
Decision ◇
43
Used to join two different flowlines in a flowchart
Connector ◯
44
Used to connect symbols and indicate the flow of logic of a flowchart
Flowline / arrows →