- •Cover Page
- •Java Programming: Contents
- •Java Programming: Preface to the Third Edition
- •Java Programming: Preface to Previous Edition
- •Java Programing: Chapter 1
- •Java Programing: Section 1.1
- •Java Programing: Section 1.2
- •Java Programing: Section 1.3
- •Java Programing: Section 1.4
- •Java Programing: Section 1.5
- •Java Programing: Section 1.6
- •Java Programing: Section 1.7
- •Java Programing: Chapter 1 Quiz
- •Java Programing: Chapter 2 Index
- •Java Programing: Section 2.1
- •Java Programing: Section 2.2
- •Java Programing: Section 2.3
- •Java Programing: Section 2.4
- •Java Programing: Section 2.5
- •Java Programing: Chapter 2 Exercises
- •Java Programing: Chapter 2 Quiz
- •Java Programing: Chapter 3 Index
- •Java Programing: Section 3.1
- •Java Programing: Section 3.2
- •Java Programing: Section 3.3
- •Java Programing: Section 3.4
- •Java Programing: Section 3.5
- •Java Programing: Section 3.6
- •Java Programing: Section 3.7
- •Java Programing: Chapter 3 Exercises
- •Java Programing: Chapter 3 Quiz
- •Java Programing: Chapter 4 Index
- •Java Programing: Section 4.1
- •Java Programing: Section 4.2
- •Java Programing: Section 4.3
- •Java Programing: Section 4.4
- •Java Programing: Section 4.5
- •Java Programing: Section 4.6
- •Java Programing: Section 4.7
- •Java Programing: Chapter 4 Exercises
- •Java Programing: Chapter 4 Quiz
- •Java Programing: Chapter 5 Index
- •Java Programing: Section 5.1
- •Java Programing: Section 5.2
- •Java Programing: Section 5.3
- •Java Programing: Section 5.4
- •Java Programing: Section 5.5
- •Java Programing: Chapter 5 Exercises
- •Java Programing: Chapter 5 Quiz
- •Java Programing: Chapter 6 Index
- •Java Programing: Section 6.1
- •Java Programing: Section 6.2
- •Java Programing: Section 6.3
- •Java Programing: Section 6.4
- •Java Programing: Section 6.5
- •Java Programing: Section 6.6
- •Java Programing: Section 6.7
- •Java Programing: Chapter 6 Exercises
- •Java Programing: Chapter 6 Quiz
- •Java Programing: Chapter 7 Index
- •Java Programing: Section 7.1
- •Java Programing: Section 7.2
- •Java Programing: Section 7.3
- •Java Programing: Section 7.4
- •Java Programing: Section 7.5
- •Java Programing: Section 7.6
- •Java Programing: Section 7.7
- •Java Programing: Section 7.8
- •Java Programing: Chapter 7 Exercises
- •Java Programing: Chapter 7 Quiz
- •Java Programing: Chapter 8 Index
- •Java Programing: Section 8.1
- •Java Programing: Section 8.2
- •Java Programing: Section 8.3
- •Java Programing: Section 8.4
- •Java Programing: Section 8.5
- •Java Programing: Chapter 8 Exercises
- •Java Programing: Chapter 8 Quiz
- •Java Programing: Chapter 9 Index
- •Java Programing: Section 9.1
- •Java Programing: Section 9.2
- •Java Programing: Section 9.3
- •Java Programing: Section 9.4
- •Java Programing: Chapter 9 Exercises
- •Java Programing: Chapter 9 Quiz
- •Java Programing: Chapter 10 Index
- •Java Programing: Section 10.1
- •Java Programing: Section 10.2
- •Java Programing: Section 10.3
- •Java Programing: Section 10.4
- •Java Programing: Section 10.5
- •Java Programing: Chapter 10 Exercises
- •Java Programing: Chapter 10 Quiz
- •Java Programing: Chapter 11 Index
- •Java Programing: Section 11.1
- •Java Programing: Section 11.2
- •Java Programing: Section 11.3
- •Java Programing: Section 11.4
- •Java Programing: Section 11.5
- •Java Programming, Chapter 11 Exercises
- •Java Programming, Chapter 11 Quiz
- •Java Programing: Appendix 1 Index
- •Java Programing: Appendix 1, Section 1
- •Java Programing: Appendix 1, Section 2
- •Java Programing: Appendix 1, Section 3
- •Some Notes on Java Programming Environments
Java Programing: Chapter 9 Quiz
Quiz Questions
For Chapter 9
THIS PAGE CONTAINS A SAMPLE quiz on material from Chapter 9 of this on-line Java textbook. You
should be able to answer these questions after studying that chapter. Sample answers to all the quiz questions can be found here.
Question 1: What does it mean to say that a program is robust?
Question 2: Why do programming languages require that variables be declared before they are used? What does this have to do with correctness and robustness?
Question 3: What is "Double.NaN"?
Question 4: What is a precondition? Give an example.
Question 5: Explain how preconditions can be used as an aid in writing correct programs.
Question 6: Java has a predefined class called Throwable. What does this class represent? Why does it exist?
Question 7: Write a subroutine that prints out a 3N+1 sequence starting from a given integer, N. The starting value should be a parameter to the subroutine. If the parameter is less than or equal to zero, throw an IllegalArgumentException. If the number in the sequence becomes too large to be represented as a value of type int, throw an ArithmeticException.
Question 8: Some classes of exceptions require mandatory exception handling. Explain what this means.
Question 9: Consider a subroutine processData that has the header
static void processData() throws IOException
Write a try...catch statement that calls this subroutine and prints an error message if an
IOException occurs.
Question 10: Why should a subroutine throw an exception when it encounters an error? Why not just terminate the program?
[ Answers | Chapter Index | Main Index ]
http://math.hws.edu/javanotes/c9/quiz.html [5/24/2000 8:40:02 AM]
