Free Exam: Prog 1 - Chapter 4
Number of Questions in Test: 13
Number of Questions in Preview: 5
Register to view all questions.
Note: Answers are not shown below but will be copied with this test.
Copy this test to my quiz maker account
Register with ClassMarker to copy free tests to give to your Test takers.
Register nowQuestion 1
The Random class was introduced in this chapter. It generates a random number of value 0 to n-1, where [b]n[/b] is passed into the generator to simulate random events like a roll of dice. What is the range of values generated by the following code?
[size=3]generator.nextInt(20);[/size]
[size=3]generator.nextInt(20);[/size]
Type: | Multiple choice |
Points: | 1 |
Randomize answers: | Yes |
Question 2
The Math class contains library methods to calculate certain math values (absolute value, max or 2 numbers, min of 2 numbers, exponent (given the base and exponent), and square root. To [b]use[/b] them, we need to instantiate the Math class.
Type: | Multiple choice |
Points: | 1 |
Randomize answers: | No |
Question 3
A Boolean expression is one that can be evaluated as being true or false. To properly use the if and while structures, you have to construct a Boolean expression that the computer can evaluate to determine program flow. Which of the below examples correctly demonstrates a Boolean expression that results in the program going into the if structure ?
Type: | Multiple choice |
Points: | 1 |
Randomize answers: | Yes |
Question 4
When evaluating an expression, Java performs operations of higher _______first, unless overridden by ______________.
Type: | Multiple choice |
Points: | 1 |
Randomize answers: | Yes |
Question 5
Loops are Java's way of executing a block of code multiple times. The two types of loops we learned are called:
Type: | Multiple choice |
Points: | 1 |
Randomize answers: | Yes |