preFinals ComPro1 Flashcards
(52 cards)
is a statement that is used to control the flow of a program.
Control structures
There are two (2) control structures:
Selection structures
Repetition structures
the program executes particular statements depending on the given condition. This alters
the flow of program execution by making a selection or choice.
Selection structures
the program repeats particular statements a certain number of times, depending on the given condition.
Repetition structures
Java provides three (3) selection structures:
if and if…else statements and switch statement.
statements are used to create one-way, two-way, and multiple selections.
if and if..else statements
is used to test a single
variable against a series of values.
Switch statement
is a reserved word, followed by the expression enclosed in parentheses.
The expression can be a relational or a logical expression that returns either true or false value.
if statement
are used to choose between two (2) alternatives.
Two way selection
are incorporated using the if statement.
One way selections
is used to implement twoway selections in Java.
if…else statements
– these are any kind of statements grouped together within curly braces.
Compound Statements or block of statements
When one (1) control statement, either selection or repetition, is located within another, it is said to be nested.
Multiple selections
When one (1) control statement, either selection or repetition, is located within another, it is said to be nested.
Multiple selections
is a process in which the computer evaluates a logical expression from left to right and stops as
soon as the value of the expression is determined.
Short-Circuit Evaluation
These logical are short-circuit operators: (2 items)
AND &&
OR ||
statement allows a single variable to be tested for equality against a list of values and, depending on its value,
executes a certain block of statements.
Switch statement
The variable used in a switch statement can only be type:
int, byte, short, char, and String
Java provides three (3) repetition (or looping) structures that are used to execute a block of statements repeatedly:
while,
for, and do…while loop. while, for, and do.. are all reserved words.
loop repeats a block of statements while a given condition evaluates to true. It evaluates the condition before executing the loop body.
While loop
loop that continues to execute endlessly is called
Infinite loop
executes a sequence of statements multiple times and abbreviates the code that manages the loop variable. It is used when a definite number of loop iterations is required.
For loop
indicates the starting value for the loop control variable
Initialization
the loop condition that controls
the loop entry
Condition