Conditionals

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/19

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:19 PM on 8/15/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

20 Terms

1
New cards

What is the basic syntax of a Java if statement?

if (condition) {

statements;

}

2
New cards

What does an else block do?

It executes when the if condition is false.

3
New cards

How many branches can execute in a basic if ... else statement?

One: either the if branch or the else branch.

4
New cards

What is the general syntax of if ... else?

if (condition) {

statements;

} else {

statements;

}

5
New cards

How does Java achieve the functionality of Python's elif?

Using else if.

6
New cards

What happens when one condition in an if / else if / else chain is true?

That branch executes and the remaining branches are skipped.

7
New cards

What is the purpose of the final else in an else if chain?

It executes if none of the preceding conditions are true.

8
New cards

What is another Java statement that implements multiway branching besides if statements?

The switch statement.

9
New cards

What determines which branch of a switch is executed?

The value of its controlling expression.

10
New cards

What is the controlling expression?

The expression enclosed in parentheses after the switch keyword.

11
New cards

What does each case contain?

A case label followed by a sequence of statements.

12
New cards

What must be true about the type of a case label?

It must be the same type as the controlling expression.

13
New cards

Do case labels have to cover every possible value?

No.

14
New cards

What does break do inside a switch?

It causes execution of the switch statement to end.

15
New cards

What happens if break is omitted after a case?

Execution continues into the next case.

16
New cards

What is this behaviour called where each case follows the next?

Fall-through

17
New cards

When does a switch stop executing?

When a break is executed or when the end of the switch statement is reached.

18
New cards

Where is default usually placed in the switch statement?

It is usually placed at the end.

19
New cards

When is default executed?

When none of the case labels matches the controlling expression.

20
New cards

What is a common use for default?

Displaying an error message when an invalid/unexpected value is supplied.