Quiz 3
Version 1

 

 

1. How many digits of precision is a float accurate to (approximately)?

2. What values can a boolean variable have?

3. If position is a variable, what does the statement position = position + 1; do?

4. What happens if you pass a value of type float to a method that is expecting a value of type double?

5. If wartcount is a variable, what does the statement wartcount--; do?

6. How do you take the square root of a number in Java?

7. You want to force a floating point number to print with exactly 4 digits after the decimal point. What two methods from HMCSupport do you need to call before you call print or println?

8. Robbie the Robot is minding the entrance to Platt dining hall, to ensure that the number of people inside does not exceed what is allowed by fire code. The number of people inside will be stored as an integer variable. What is the smallest integer type you can reasonably declare this variable to be?

9. Robbie's micro-miniaturized cousin counts the number of people inside Sprague library's elevator. What type of variable does she need to store her count?

10. What happens if you pass a value of type float to a method that is expecting a value of type int?

Last modified August 28 for Fall 99 cs5 by fleck@cs.hmc.edu


This page copyright ©1998 by Joshua S. Hodas. It was built with Frontier on a Macintosh . Last rebuilt on Sun, Sep 6, 1998 at 1:36:00 PM.
http://www.cs.hmc.edu/~hodas/courses/cs5/week_03/quiz.html