chap 4 - revisited Flashcards Preview

Java 1 > chap 4 - revisited > Flashcards

Flashcards in chap 4 - revisited Deck (14)
Loading flashcards...

what is a conditional?

conditionals are if else statements that must be met in order for something to take place.


when using a conditional with multiple if statements then how do the else statements interact with those if statements?

the else automatically associates with the most recently used if statement. force an else statement to work with a prior if statement then we must use ( ) around the nested if statements so that they dont associate with the else statement.
if (argument here)
if (argument here)
else (*output here);
^^the else statement will work with the second if statement and not the 1st unless we put ( ) around the second nested if statement.


what are nested if statements?

when an if statement is followed by another if statement before an else statement.


what is the structure of an If statement?

If statement:
if --> conditional --> statement

conditional uses boolean arguments often.


example of a conditional where the variable conditional is less than 17
then print to the screen "the conditions have been met"

if (conditional < 17)
System.out.println("The conditions have been met");


when using a conditional is there a way to have operators for: and .. or statements?

yes the operators used:
&& and
|| OR


block statement? is what?

block statement:
group of statements and declarations deliminated (within) braces { }.


what are nested if statements?

nested if statements:
an if condition with another if statement within its body.


when using nested if statements does the else statement line up with the first if ?

the else statement always matches up with the closest unmatched if statement unless ( ) are used to force otherwise.


how to stop an infinite loop in a program what do you do?

press CTRL + C


what is the format of a while loop?

while (boolean argument)
{ what happens such as adding one
This is the body of the loop that is executed until the boolean is met.}


what is an infinite or endless loop?

an error where a while loop never ends due to a logic error.


what are the sections of a for loop? (3)

initialization -- initializes a variable with a value
Condition -- basically a boolean
increment --- the variable with ++ one added on,


what are the sections of a for loop? (3)

initialization -- initializes a variable with a value
Condition -- a boolean
increment --- the variable with ++ one (or other amount) added on After
The body of the loop is executed each time.