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?
  1. Delete the method in the superclass.

  2. Override the method in the subclass.

  3. 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?
  1. get()

  2. read()

  3. elementAt()

3:What statement can you use to refer to the methods and variables of the current object?
  1. this

  2. that

  3. theOther

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 ...

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.