1/22
Comprehensive review flashcards covering Java control structures (selection, repetition, and branching) and console input/output mechanisms using Scanner, System.out, and System.in.
What are the three types of control statements supported in Java?
Selection, Repetition, and Branching.
Which decision-making statements are categorized as selection statements in Java?
The if, if-else, and switch statements.
In Java programming, how is a block defined?
A block is the set of statements enclosed between two curly braces ({, }).
Which primitive data types can be evaluated against case constants in a Java switch statement?
byte, short, char, and int primitive data types only.
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.
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.
What is the term for the variable evaluated in a loop's Boolean expression?
The loop control variable.
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.
When is a for loop preferred over while and do-while loops?
When the number of repetitions or iterations is known in advance.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
What standard input device is represented by System.in in Java?
The keyboard.
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.
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.