1. In Java all classes can inherit attributes (instance variables) and behaviors (methods) from another class.
2. The class being inherited from is called the _______________. The class that is inheriting is called the child class or subclass.
3. A car is a kind of ___________. This is sometimes called the is-a relationship, but more accurately it's a is-a kind of relationship.
4. A _________ class diagram shows classes and the relationships between the classes
5. Refer to the above image. The parent class for Professor and Student is ________. The _______ class has ____ child classes or subclasses.
6. Fill in the blanks for the following:
While a person can have two parents,
a Java class can only inherit from one parent class.
If you leave off the ________ keyword when you
declare a class then the class will inherit
from the Object class that is already defined
in Java.
7. The class Vehicle has the instance fields make and model. The class Car inherits from the class Vehicle but the car object will not automatically have the fields make and model.
8. What type of inheritance does Java have?
9. Say that there are three classes: Computer, AppleComputer, and IBMComputer. What are the likely relationships between these classes?
10. How many objects of a given class can there be in a program?
11. What restriction is there on using the super reference in a constructor?
12. Which of the following is correct syntax for defining a new class Cokeo based on the superclass SoftDrink?
13. A class Animal has a subclass Mammal. Which of the following is true:
14. A subclass inherits both member variables and methods.
15. Which of the following is NOT an advantage to using inheritance?
16. A bookstore has an on-line ordering system. For each type of published material (books, movies, audio tapes) they need to track the id, title, author(s), date published, and price. What would be the best design?
17. Given the following class declarations, what is the output from Student s1 = new ComputingStudent(); followed by s1.getInfo();?
18. Given the following class declarations and initializations in a client program, which of the following is a correct call to method1?
19. Assume that Base b = new Derived(); appears in a client program. What is the result of the call b.methodOne();?
20. Read the following excerpt and decide whether it is true or false.