CIS 163 AA - Java Programming I - Section 5811
Worksheet #4
Due
Monday, October 10, 2005
Name:
I. Definitions: please explain the following terms:
- object
- instance
- instance data
- local data
- scope
- return type
- constructor
- parameter
- mutator method
- listener
II. Question or short essay
- What is the difference between an object and a class?
- What does the return statement do?
- How is a constructor different from a regular method?
- How is private visibility different from public visibility?
- What is the difference between a formal parameter and an
actual parameter?
- 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.