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

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

A

Nested if

21
Q

Two conditions must be met before some action is taken

A

Nested if

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
Q

_________ operator takes 3 arguments

A

ternary

26
Q

Ternary operator syntax:

A

expression1 ? expression2 : expression3

(this means that If expression1 is true, the result of the conditional expression is expression2. Otherwise, the result is expression3)

27
Q

An alternative to a series of nested if statements

A

Switch statements

28
Q

Test a single variable against a series of exact integer, character, or string values

A

Switch statements

29
Q

Switch statement keywords: (4)

A
  • switch
  • case
  • break
  • default
30
Q

Starts the switch structure followed by a test expression enclosed in parentheses

A

switch

31
Q

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

A

case

32
Q

In a switch statement when a case value is matched, all statements after it execute until a ______ is encountered

A

break

33
Q

The break statement may or may not appear after each statement in switch statements
(True or False)

A

T

34
Q

Switch statement:
Optionally ________ is used prior to any action that should occur if the test variable does not match any case

A

default

35
Q

There are two types of algorithm:

A

Pseudocode
Flowchart

36
Q

Plan a program’s logic by writing plain English statements

A

Pseudocode

37
Q
  • Steps in diagram form
  • A series of shapes connected by arrows
A

Flowchart

38
Q

The six (6) basic flowcharting symbols are:

A
  • Terminator ⬭
  • Input/Output ▱
  • Process ▭
  • Decision ◇
  • Connector ◯
  • Flowline / arrows →
39
Q

used to represent the start and end of a flowchart

A

Terminator ⬭

40
Q

used for input and output decisions in a flowchart

A

Input/Output ▱

41
Q

used for arithmetic and data manipulation operations in a flowchart

A

Process ▭

42
Q

used for logic of comparison operations in a flowchart

A

Decision ◇

43
Q

Used to join two different flowlines in a flowchart

A

Connector ◯

44
Q

Used to connect symbols and indicate the flow of logic of a flowchart

A

Flowline / arrows →