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
How many times will the following do-while loop be executed?
int x = 11;
Do
{
X += 20;
} while (x <= 100);
Free
(Multiple Choice)
4.8/5
(33)
Correct Answer:
A
Which of the following statements will create an object from the Random class?
Free
(Multiple Choice)
4.8/5
(35)
Correct Answer:
B
When you open a file with the PrintWriter class, the class can potentially throw an IOException.
Free
(True/False)
4.8/5
(50)
Correct Answer:
True
The variable used to keep a running total in a loop is called a(n) __________.
(Multiple Choice)
4.8/5
(37)
A loop that repeats a specific number of times is known as a(n) __________ loop.
(Multiple Choice)
4.9/5
(40)
What will be the value of x after the following statements are executed?
int x = 10;
For (int y = 5; y < 20; y +=5)
X += y;
(Multiple Choice)
4.9/5
(38)
What will be the values of x and y as a result of the following code?
int x = 25, y = 8;
X += y++;
(Multiple Choice)
4.9/5
(44)
Given the following statement, which statement will write the string "Calvin" to the file DiskFile.txt?
PrintWriter diskOut = new PrintWriter("DiskFile.txt");
(Multiple Choice)
4.7/5
(34)
Before entering a loop to compute a running total, the program should first
(Multiple Choice)
4.7/5
(36)
Select all that apply. Which method of the Random class will return a random number within the range of 0.0 and 1.0?
(Multiple Choice)
4.8/5
(35)
A random number, created as an object of the Random class, is always a(n) __________.
(Multiple Choice)
4.8/5
(44)
The variable that controls the number of times a loop iterates is known as a(n) __________.
(Multiple Choice)
4.7/5
(50)
In a for loop, the control variable cannot be initialized to a constant value and tested against a constant value.
(True/False)
4.8/5
(42)
In all but very rare cases, loops must contain, within themselves
(Multiple Choice)
4.8/5
(44)
The while loop is always the best choice in situations where the exact number of iterations is known.
(True/False)
4.8/5
(40)
The __________ loop is ideal in situations where the exact number of iterations is known.
(Multiple Choice)
4.8/5
(34)
How many times will the following do-while loop be executed?
int x = 11;
Do
{
X += 20;
} while (x > 100);
(Multiple Choice)
4.8/5
(42)
What will be the values of x aand y after the following code is executed? int x = 12, y = 5;
X += y--;
(Multiple Choice)
4.8/5
(35)
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
(43)
Showing 1 - 20 of 56
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)