A loop that repeats a specific number of times is known as a(n) _____________. |
Count-controlled loop |
What will be the value of x after the following code is executed? |
15 |
This is a value that signals when the end of a list of values has been reached. |
Sentinel |
This type of loop will always be executed at least once. |
Post-test loop |
Which of the following are pre-test loops: |
while, for |
What will be the value of x after the following code is executed? |
100 |
In the following code, what values could be read into number to terminate the while loop? Scanner keyboard = new Scanner(System.in); |
The boolean condition can never be true |
How many times will the following do-while loop be executed? |
1 |
Which of the following will open a file named MyFile.txt and allow you to append data to its existing contents? A) FileWriter fwriter = new FileWriter("MyFile.txt"); |
B) FileWriter fwriter = new FileWriter("MyFile.txt", true); PrintWriter outFile = new PrintWriter(fwriter); |
What will be printed after the following code is executed? |
5, 8, 11, 14 |
This type of loop is ideal in situations where the exact number of iterations is known. |
for loop |
What will be the value of x after the following code is executed? |
200 |
You can use this method to determine whether a file exists. |
The File class’s exists method |
This is an item that separates other items. |
Delimiter |
How many times will the following for loop be executed? |
12 |
In all but rare cases, loops must contain within themselves |
A way to terminate |
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? |
D) int number = inputFile.nextInt(); |
If a loop does not contain within itself a way to terminate, it is called |
An infinite loop |
A loop that executes as long as a particular condition exists is called a(n) _____. |
Conditional loop |
A sentinel value ____________ and signals that there are no more values to be entered. |
Is a special value that cannot be mistaken as a member of the list |
This is a sum of numbers that accumulates with each iteration of a loop. |
Running total |
What will be the value of x after the following code is executed? int x = 10, y = 20; |
210 |
In the following code, what values could be read into number to terminate the while loop? |
Numbers in the range 100 through 500 |
When you open a file with the PrintWriter class, the class can potentially throw an IOException |
True |
True or False |
True |
True or False |
False |
True or False\ |
False |
True or False When you pass the name of a fi le to the PrintWriter constructor, and the file already |
True |
True or False |
False |
True or False The do-while loop is a pre-test loop. |
False |
Java Chapter 5
Share This
Unfinished tasks keep piling up?
Let us complete them for you. Quickly and professionally.
Check Price