Java Reference
In-Depth Information
Quiz
Review today's material by taking this three-question quiz.
Questions
1. If you use this in a method call such as addActionListener(this) , what object
is being registered as a listener?
a. An adapter class
b. The current class
c. No class
2. What is the benefit of subclassing an adapter class such as WindowAdapter (which
implements the WindowListener interface)?
a. You inherit all the behavior of that class.
b. The subclass automatically becomes a listener.
c. You don't need to implement any WindowListener methods you won't be
using.
3. What kind of event is generated when you press Tab to leave a text field?
a. FocusEvent
b. WindowEvent
c. ActionEvent
Answers
1. b. The current class must implement the correct listener interface and the required
methods.
2. c. Because most listener interfaces contain more methods than you will need, using
an adapter class as a superclass saves the hassle of implementing empty methods
just to implement the interface.
3. a. A user interface component loses focus when the user stops editing that compo-
nent and moves to a different part of the interface.
12
Certification Practice
The following question is the kind of thing you could expect to be asked on a Java pro-
gramming certification test. Answer it without looking at today's material or using the
Java compiler to test the code.
 
Search WWH ::




Custom Search