ITEC 120 LAB 19 Back to Lab index page

Inheritance

You will create a class called Pet and an inherited class called Dog.

Pet
# name: String
# age : int
+ toString():String

Dog
- breed: String
- treat : String
+ toString():String

In the Pet.java file:

In the Dog.java file:

Write a driver program which will instantiate one Pet object and two Dog objects. Make up data to pass to the constructors. Then print out each object you instantiated.

Once you have your program working, show your lab to the Peer Instructor to be checked off.