Exam 4: Loops and Files
Exam 1: Introduction to Computers and Java53 Questions
Exam 2: Java Fundamentals52 Questions
Exam 3: Decision Structures58 Questions
Exam 4: Loops and Files56 Questions
Exam 5: Methods56 Questions
Exam 6: A First Look at Classes58 Questions
Exam 7: Arrays and the Arraylist Class63 Questions
Exam 8: A Second Look at Classes and Objects52 Questions
Exam 9: Text Processing and More About Wrapper Classes62 Questions
Exam 10: Inheritance64 Questions
Exam 11: Exceptions and Advanced File Io59 Questions
Exam 12: Java-Fx: Gui Programming and Basic Controls42 Questions
Exam 13: Java-Fx: Advanced Controls40 Questions
Exam 14: Java-Fx: Graphics, Effects, and Media40 Questions
Exam 15: Recursion23 Questions
Exam 16: Databases40 Questions
Select questions type
Which of the following statements opens a file named MyFile.txt and allows you to append data to its existing contents?
(Multiple Choice)
4.8/5
(28)
A file must always be opened before using it and closed when the program is finished using it.
(True/False)
4.7/5
(45)
What will be the value of x after the following code is executed?
int x = 10, y = 20;
While (y < 100)
{
X += y;
Y += 20;
}
(Multiple Choice)
4.7/5
(44)
What will be the value of x after the following code is executed?
int x = 10, y = 20;
While (y < 100)
{
X += y;
}
(Multiple Choice)
4.9/5
(29)
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/False)
4.9/5
(27)
Which is a control structure that causes a statement or group of statements to repeat?
(Multiple Choice)
4.9/5
(41)
Assume that inputFile references a Scanner object that was used to open a file. Which of the following while loops is the correct way to read data from the file until the end of the file is reached?
(Multiple Choice)
4.8/5
(37)
A loop that executes as long as a particular condition exists is called a(n) __________ loop.
(Multiple Choice)
4.9/5
(35)
What will be the value of x after the following code is executed?
int x, y = 15;
X = y--;
(Multiple Choice)
4.8/5
(28)
When the continue 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.
(True/False)
4.8/5
(48)
When working with the PrintWriter class, which of the following import statements should you have near the top of your program?
(Multiple Choice)
4.9/5
(34)
The __________ loop allows the user to decide on the number of iterations.
(Multiple Choice)
4.8/5
(35)
Which of the following is the method you can use to determine whether a file exists?
(Multiple Choice)
4.7/5
(34)
In the following code, what values could be read into number to terminate the while loop? Scanner keyboard = new Scanner(System.in);
System.out.print("Enter a number: ");
Int number = keyboard.nextInt();
While (number < 100 || number > 500)
{
System.out.print("Enter another number: ");
Number = keyboard.nextInt();
}
(Multiple Choice)
4.9/5
(37)
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/False)
4.9/5
(41)
Showing 41 - 56 of 56
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)