Java Control Structures and Console Input/Output

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

1/22

flashcard set

Earn XP

Description and Tags

Comprehensive review flashcards covering Java control structures (selection, repetition, and branching) and console input/output mechanisms using Scanner, System.out, and System.in.

23 Terms

1
New cards

What are the three types of control statements supported in Java?

Selection, Repetition, and Branching.

2
New cards

Which decision-making statements are categorized as selection statements in Java?

The if, if-else, and switch statements.

3
New cards

In Java programming, how is a block defined?

A block is the set of statements enclosed between two curly braces ({, }).

4
New cards

Which primitive data types can be evaluated against case constants in a Java switch statement?

byte, short, char, and int primitive data types only.

5
New cards

What rule governs the placement of the default label within a switch construct?

The default label must always be the last option in the switch construct if used.

6
New cards

What occurs during program execution if a break statement is omitted in a switch case?

Control passes to the next case statement, causing the remaining statements to be executed.

7
New cards

What is the term for the variable evaluated in a loop's Boolean expression?

The loop control variable.

8
New cards

Why is the do-while construct classified as a post-test loop statement?

Because the statements in the do block are executed before the while condition is checked, guaranteeing the body executes at least once even if the condition is false on the first attempt.

9
New cards

When is a for loop preferred over while and do-while loops?

When the number of repetitions or iterations is known in advance.

10
New cards

What are the three expressions enclosed within the parentheses of a standard for loop header?

The initialization expression, the test expression, and the increment/decrement expression.

11
New cards

What happens if a programmer mistakenly terminates a for loop header with a semicolon?

It becomes a self-executing for loop that advances to the following statement block only after the loop condition evaluates to false.

12
New cards

What is the difference between an unlabeled break statement and a labeled break label statement?

The unlabeled break; terminates the innermost loop or switch construct, whereas break label; terminates the outermost loop in a series of nested loops.

13
New cards

What action does the continue statement perform within a loop?

It skips the remainder of the current iteration and resumes execution at the next iteration.

14
New cards

What are the two functional forms of the return statement?

One form returns an evaluated value to the caller method, and the other (return;) returns nothing and is used in methods declared with a void return type.

15
New cards

How is input defined in the context of computer software?

The process of entering data into software running on a computer through typed text, various types of files, or mouse commands.

16
New cards

What is Java's default standard output device, and what object represents console output?

The default standard output device is the computer monitor, and Java references console output using System.out.

17
New cards

What is the functional difference between System.out.print() and System.out.println()?

The print method outputs the text and leaves the cursor at the end of the string on the same line, whereas println outputs the text and moves the cursor down to the next line.

18
New cards

What is the Java API?

A predefined set of classes used in any Java program that are organized into packages and are not part of the core language itself.

19
New cards

Under what circumstance does a standalone System.out.println(); statement produce a blank line?

Only when there is not a preceding System.out.print(); statement on the same code segment.

20
New cards

Which package is automatically imported into all Java programs without requiring an explicit import statement?

The java.lang package, which includes classes such as System and Math.

21
New cards

What standard input device is represented by System.in in Java?

The keyboard.

22
New cards

What are the specific Scanner class methods used to read an integer, a double, a single word, and an entire line of text?

nextInt() reads an integer, nextDouble() reads a double, next() reads a single String word ending before a space, and nextLine() reads an entire line of text as a String.

23
New cards

In console input programming, what is a prompt?

An output message displayed before an input method to instruct the user on what value is expected to be entered.