Ch. 4 Control Statements Flashcards

1
Q

Before writing a porgram to solve a problem.

A
  • You must have a thorough understanding of teh problem and a carefully planned approach to solving it.
  • You must also understand the building blocks that are avaiable and employ proven program construction techniques
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Any computing problem can be solved by….

A

Executing a series of actions in a specific order.

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

ALGORITHM

A

Procedure for solving a problem in terms of the actions to execute and the order in which they execute is called an algorithim.

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

Program Control

A

Specifying the order in which statements execute in a program is called program control.

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

Pseudocode

A

An informal language that helps you develop algorithms without having to worry about the strict details of java language syntax

Similar to everyday english, its convenient to user friendly, but it’s not an actual computer programing language

Helps you “think out” a program before attempting to write it in a programing language such as java.

Carefully prepared pseudocode can easily be converted to a corresponding java program.

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

Sequential Execution

A

Statements in a program executed one after the other in which they’re written

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

Transfer of Control

A

Various Java statements enable you to specify that the next statement to execute is not necessarily the next one in sequence.

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

Control Structure

A
  • Comes from the field of computer science
  • The Java Language Specification refers to “control structures” as “control statements”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Selection Statements

A
  • The if statement either performs (selects) an action, if a condition is true, or skips it if it is false.
  • 3 Types: Single-Selection, Double Selection Statement, Multiple Selection Statement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Java provides the while, do…while and for repetition (looping) statements

A
  • Enable programs to perform statements repeatedly as long as a loop-continuation condition remains true
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The while and for statements

perform the actions in….

A
  • Their bodies zero or more times - if the loop continuation condition is initially false,the action will not execute.
  • The do…while statement performs the action(s) in its body one or more times.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The words:

if

else

switch

while

do

for

A
  • Java keywords
  • Keywords can not be used as identifiers, such as variable names
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Every program is formed by…

A

Combining as many sequence, selection, and repetition statements as is appropriate for the algorithim the program implements.

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

if Single-Selection Statement

A
  • Programs use selection statements to choose among alternative courses action
  • The if statement is a single-entry/single-exit control statement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Control Statement Stacking

A

Single-entry/single exit control statements are attached to one another by connecting the exit point of one to the entry point of the next.

Control statement may also be nested inside another control statement

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

if…else Double-Selection Statement

A
  • Performs one action when the condition is true and a different action when the condition is false
  • The conditional operator is Java’s only ternary operator
17
Q

All Programs can be written in terms of three types of control structures: _____ ______ and _____

A
  • Sequence
  • Selection
  • Reptition
18
Q

The _____ statement is used to execute one action when a condition is true and another when the condition is false.

A

if…else statement

19
Q

Repeating a set of instructions a specific number of times is called ______ repetitiion.

A

Counter-Controlled

or

Definite

20
Q

When it’s not known in advance how many times a set of statements will be repeated, a(n)_____ value can be used to terminate repetition.

A

sentinel

signal

flag

dummy

21
Q

The _____ structure is built into Java; by default, statements execute in the order they appear

A

sequence structure

22
Q

Instance variables of types char, byte, short, int, long, float and double are all given the value _____ by default

A

0 (zero)

23
Q

Java is a(n)______ language; it requires all variables to have a type.

A

strongly typed

24
Q

If the increment operator is ______ to variable, first the variable is incremented by 1, then its new value is used in the expression

A

prefixed

25
Q

An alogorithm is a procedure for solving a problem in terms of the actions to execute and the order in which they execute.

True or False

A

TRUE

26
Q

A set of statements contained within a pair of parentheses is called a block.

A

FALSE

A set of statements contained within a pair of braces{ } is called a block

27
Q

A selection statement specifies that an action is to be repeated while some condition remains true.

True or False

A

FALSE

A repetition statement specifies that an action is to be repeated while some condition remains true

28
Q

A nested control statement appears in the body of another control statement

A

True

29
Q

Java provides the arithmetic compound assignment operators +=, -=, *=, /=, and %= for abbreviating assignment expressions.

A

TRUE

30
Q

The primitive types

(boolean, char, byte, shor, int, long, float, and double)

are portable across only Windows Platforms

A

FALSE

The primitive types

(boolean, char, byte, shor, int, long, float, and double)

are portable across ALL computer platforms that support Java.

31
Q

Specifying the order in which statements execute in a program is called program control.

A

TRUE

32
Q

The unary cast operator (double) creates a temporary integer copy of its operand.

A

FALSE

The unary cast operator (double)

creates a temporary floating-point copy of its operand.

33
Q

Instance variables of type boolean are given the value true by default

A

FALSE

Instance variables of type boolean

are given the value false by default