Programming Fundamentals I Exam 2 (Chapter 3 & 4)

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which relational operators test for two relationships?

>= and <=

Which type of file contains data that has not been converted to text?

Binary File

The _____ statement causes a loop to terminate early.

Break

The _____ statement causes a loop to stop its current iteration and begin the next one.

Continue

A loop that repeats a specific number of times is known as a(n) _____.

Count-Controlled Loop

In a flowchart, which symbol represents a yes/no question or a true/false condition?

Diamond

Because the for loop evaluates its test expression after it performs an iteration, it is known as a posttest loop.

False

If you inadvertently put a semicolon after the if(expression) portion of an if statement, the statement following the if will never execute.

False

Only increment statements may be used in the update expression of a for loop.

False

The ?: operator has higher precedence than the + operator.

False

The else part at the end of the if statement specifies a statement that is to be executed w

False

True or False: When you write a switch statement using arrow case syntax, you must have a break statement in each case section.

False

to open a file for reading, you use the following classes.

File and Scanner

If a loop does not have a way of stopping, it is called a(n) _____.

Infinite loop

Data is read from a(n) ___________ file.

Input

A loop that is inside another loop is called a(n) _____.

Nested Loop

The _______________ Java class can be used to write data to a file.

PrintWriter

this class allows you to use the print and println methods to write data to a file

PrintWriter

to open a file for writing, you use the following class

PrintWriter

you can use this method to display formatted output in a console window.

System.out.printf

The last else clause in the if/else if statement, which is optional and does not have an if statement following it, is referred to as a(n) _______.

Trailing else

A conditionally executed statement should be indented one level from the if clause.

True

A sentinel is a special value that cannot be mistaken as a member of the list and signals that there are no more values to be entered.

True

All it takes for an OR expression to be true is for one of the sub-expressions to be true.

True

All modifications of the for loop's counter variable should take place in the update expression, which is automatically executed at the end of each iteration.

True

An important characteristic of the while loop is that the loop will never iterate if the boolean expression is false to start with.

True

Any method that uses PrintWriter objects and does not respond to their exceptions must have the clause throws IOEXception.

True

Even though if statements usually span more than one line, they are technically one long statement.

True

If the sub-expression on the left side of an && operator is false, the expression on the right side will not be checked.

True

In a decision structure's simplest form, a specific action is taken only when a specific condition exists, and if the condition does not exist, the action is not performed.

True

In most cases, loops must contain within themselves a way to terminate.

True

It is often simpler to test a series of conditions with the if/else if statement than with a set of nested if/else statements.

True

It is possible to execute more than one statement in the initialization expression and the update expression of a for loop.

True

The ! operator has a higher precedence than the && and || operators.

True

The == operator determines whether a variable is equal to another value, whereas the = operator assigns the value on the operator's right to the variable on its left.

True

The do-while loop is a posttest loop, which means it does not test its expression until it has completed an iteration.

True

The do-while loop must be terminated with a semicolon.

True

The switch statement's default section (or the last case section, if there is no default ) does not require a break statement.

True

The variable that is used to accumulate the total of the numbers is called an accumulator.

True

The while loop has two important parts: (1) a boolean expression that is tested for a true or false value, and (2) a statement or block that is repeated as long as the expression is true.

True

True or False: When using arrow case syntax in a switch statement, if you need to write more than one statement in a case section, you must enclose those statements in curly braces.

True

Variables defined inside a set of braces may only be used in the part of the program between their definition and the block's closing brace.

True

Your application should always close files when finished with them.

True

this is a variable that keeps a running total

accumulator

This type of expression has a value of either true or false

boolean expression

To create a block of statements, you enclose the statements in these.

braces {}

when a program is finished using a file, it should do this

close the file

The if statement is an example of a _____.

decision structure

This section of a switch statement is branched to if none of of the case expressions match the testExpression.

default

It is ideal in situations where you always want the loop to iterate at least once.

do-while loop

Which method determines whether two different String objects contain the same string and returns a boolean value?

equals()

it is not necessary to initialize accumulator variables

false

one limitation of the for loop is that only one variable may be initialized in the initialization expression

false

the do-while loop is a pretest loop

false

the for loop is a posttest loop

false

to calculate the total number of iterations of a nested loop, add the number of iterations of all the loops

false

true or false. the = operator and the == operator perform the same operation

false

true or false. when an if statement is nested in the else clause of another statement, the only time the inner if statement is executed is when the boolean expression of the outer if statement is true.

false

this is a boolean variable that signals when some condition exists in the program.

flag

What type of loop is specifically designed to initialize, test, and update a counter variable?

for

It is ideal in situations where the exact number of iterations is known.

for loop

this expression is executed but the for loop only once, regardless of the number of iterations

initialization expression

&&, ||, and ! are _______.

logical operators

this is a variable that controls the number of iterations performed by a loop

loop control variable

This is an if statement that appears inside another if statement

nested if statement

This is an empty statement that does nothing.

null statement

in the expression number++, the ++ operator is in what mode

postfix

the do-while loop is this type of loop

posttest

the for loop is this type of loop

pretest

the while loop is this type of loop, which means it tests its expression before each

pretest

Numeric data is compared in Java by using _______ operators.

relational

>, <, and == are _____.

relational operators

A(n) __________________ is caused by a program not closing its resources.

resource leak

If a case section in a switch expression has more than one statement, you must use the keyword to return a value from that case section.

return

What term refers to a sum of numbers that accumulates with each iteration of a loop?

running total

this is a special value that signals when there are no more items from a list of items to be processed. this value cannot be mistaken as an item from the list

sentinel

Code with a _______ structure contains statements that are executed in order, without branching off in another direction.

sequence

an else clause always goes with ______.

the closest previous if clause that doesn't already have its own else clause.

the conditional operator takes this many operands.

three

a variable may be defined in the initialization expression of the for loop, the scope of the variable is limited to the loop.

true

in a nested loop, the inner loop goes through all of its iterations for every iteration of the outer loop

true

the while loop is a pretest loop

true

true or false. all lines in a conditionally excuted block should be indented one level.

true

true or false. the scope of a variable is limited to the block in which it is defined.

true

true or false. when an if statement is nested in the if clause of another statement, the only time the inner if statement is executed is when the boolean expression of the outer if statement is true.

true

The __________________ statement is used to automatically close resources, such as files.

try-with-resources

It is ideal in situations where you do not want the loop to iterate if the condition is false from the beginning.

while loop

Which operator takes an operand and reverses its truth or falsehood?

!

this class allows you to read a line from a file

Scanner

To obtain the total number of iterations of a nested loop, multiply the number of iterations of all the loops.

True

this type of loop always executes at least once

do-while

what is each repetition of a loop known as?

iteration

this determines whether two different string objects contain the same string.

the equals method

When determining whether a number is outside a range, it's best to use the _______ operator.

||

Which operator takes two expressions as operands and creates an expression that is true when either of the sub-expressions are true?

||

Which relational operator determines whether one value is not equal to another value?

!=

Which operator takes two expressions as operands and creates an expression that is true only when both sub-expressions are true?

&&

when determining whether a number is inside a range, it's best to use this operator.

&&

How does that character 'A' compare the the character 'B'?

'A' is less than 'B'

When using arrow case syntax in a switch statement, the arrow operator is .

->


Kaugnay na mga set ng pag-aaral

Сесія українська мова

View Set

Unit A, Lesson 7: Mitosis, Meiosis, and Fertilization

View Set

Math: Fractions and Decimals 111

View Set

Pharm - Chapter 14 - Antiepileptic Drugs

View Set

H Thursday Business Management Unit 2

View Set

Webelos-describe the First Class Scout Badge

View Set