Java Reference
In-Depth Information
6. That variable never refers to a
Measurable
object. It refers to an object
of some classȌa class that implements the
Measurable
interface.
7. Both describe a situation where one method name can denote multiple
methods. However, overloading is resolved early by the compiler, by
looking at the types of the parameter variables. Polymorphism is resolved
late, by looking at the type of the implicit parameter object just before
making the call.
8. The
String
class doesn't implement the
Measurable
interface.
9. Implement a class
StringMeasurer
that implements the
Measurer
interface.
10. A measurer measures an object, whereas
getMeasure
measures Ȓitselfȓ,
that is, the implicit parameter.
11. Inner classes are convenient for insignificant classes. Also, their methods
can access variables and fields from the surrounding scope.
12. Four: one for the outer class, one for the inner class, and two for the
DataSet
and
Measurer
classes.
13. The
button
object is the event source. The
listener
object is the event
listener.
14. The
ClickListener
class implements the
ActionListener
interface.
15. Direct access is simpler than the alternativeȌpassing the variable as a
parameter to a constructor or method.
16. The local variable must be declared as
final
.
17. First add
label
to the
panel
, then add
button
.
18. The
actionPerformed
method does not access that variable.
19. The timer needs to call some method whenever the time interval expires. It
calls the
actionPerformed
method of the listener object.