Quiz
To determine what kind of knowledge you inherited from the past hour's work, answer the following questions.
Questions
1: |
If a superclass handles a method in a way you don't want to use in the subclass, what can you do?
- Delete the method in the superclass.
- Override the method in the subclass.
- Write a nasty letter to the editor of the San Jose Mercury News hoping that Java's developers will read it.
|
2: |
What methods can be used to retrieve an element stored in a vector?
|
3: |
What statement can you use to refer to the methods and variables of the current object?
|
Answers
A1: |
b. Because you can override the method, you don't have to change any aspect of the superclass or the way it works.
|
A2: |
a. The get() method has one argument, the index number of the element.
|
A3: |
a. The this keyword refers to the object in which it appears.
|
|