CIS 163 AA - Java Programming I - Section 5811
Worksheet #4
Due Monday, October 10, 2005

Name:

I. Definitions: please explain the following terms:

  1. object

  2. instance

  3. instance data

  4. local data

  5. scope

  6. return type

  7. constructor

  8. parameter

  9. mutator method

  10. listener

II. Question or short essay

  1. What is the difference between an object and a class?

  2. What does the return statement do?

  3. How is a constructor different from a regular method?

  4. How is private visibility different from public visibility?

  5. What is the difference between a formal parameter and an actual parameter?

  6. How is a method different from a class?
III. Programming Exercises Write source code for the following:

    Design and implement a class called PairOfDice. It's instance data should be two six-sided Die objects. It should have at least a constructor and a method called throw. Whenever the throw method is called it should roll the two Die objects and return the sum of the two rolls. Create a driver class with a main method that throws the dice five times and prints the values returned.