Java Chapter 4

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Java provides a set of simple unary operators designed just for incrementing and decrementing variables.

True

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

True

The variable used to keep a running total in a loop is called a(n) ________.

accumulator

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

do-while

The ________ loop allows the user to decide on the number of iterations.

user controlled loop

Which of the following are pre-test loops?

while, for

In a for loop, the control variable cannot be initialized to a constant value and tested against a constant value.

False

In a for loop, the control variable is always incremented.

False

A file must always be opened before using it and closed when the program is finished using it.

True

Assuming that inputFile references a Scanner object that was used to open a file, which of the following statements will read an int from the file?

int number = inputFile.nextInt();

When the break statement is encountered in a loop, all the statements in the body of the loop that appear after it are ignored, and the loop prepares for the next iteration.

False

The do-while loop is ideal in situations where you always want the loop to iterate at least once.

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 of statements that is repeated as long as the expression is true.

True

When you open a file with the PrintWriter class, the class can potentially throw an IOException.

True

When you pass the name of a file to the PrintWriter constructor and the file already exists, it will be erased and a new empty file with the same name will be created.

True

An item that separates other items is known as a ________.

delimiter

Given the following statement, which statement will write the string "Calvin" to the file DiskFile.txt?PrintWriter diskOut = new PrintWriter("DiskFile.txt");

diskOut.println("Calvin");

Which of the following expressions will generate a random number in the range of 1 through 10?

myNumber = randomNumbers.nextInt(10) + 1;

A(n) ________ is a special value that cannot be mistaken as a member of a list of data items and signals that there are no more data items to be processed.

sentinel

What will be the values of x and y as a result of the following code?int x = 25, y = 8;x += y++;

x = 33, y = 9


संबंधित स्टडी सेट्स

PrepUs for Pediatrics Chapter 28

View Set

Chapter 8 Human Resources management

View Set

Cultural Diversity and Conformity

View Set

AP Anatomy & physiology chapter 2 test

View Set

Black and white film👴🏿👶🏼🤑

View Set

Chapter 11: Retailing and Wholesaling

View Set

CA HA 6 UPPER apendicular system & WQ chapter 8

View Set