Java MCQs on Observable & Timer class of Java Programming Language.
1. What is the use of Observable class? Answer: b 2. Which of these methods is used to notify observer the change in observed object? Answer: a 3. Which of these methods calls update() method? Answer: d 4. Which of these methods is called when observed object has changed? Answer: d 5. Which of these classes can schedule task for execution in future? Answer: b 6. Which of these interfaces is implemented by TimerTask class? Answer: a 7. Which of these package provides the ability to read and write in Zip format? Answer: c Global Education & Learning Series – Java Programming Language.
a) It is used to create global subclasses
b) It is used to create classes that other part of the program can observe
c) It is used to create classes that can be accessed by other parts of program
d) It is used to create methods that can be accessed by other parts of program
Clarification: The Observable class is used to create subclasses that other part of program can observe.
a) update()
b) notify()
c) check()
d) observed()
Clarification: None.
a) notify()
b) observeObject()
c) updateObserver()
d) notifyObserver()
Clarification: notifyObserver() notifies all the observers of the invoking object that it has changed by calling update(). A null is passed as the second argument to update().
a) setChanged()
b) update()
c) notifyObserver()
d) all of the mentioned
Clarification: None.
a) Thread
b) Timer
c) System
d) Observer
Clarification: Timer and TimerTask are the classes that support the ability to schedule tasks for execution at some future time.
a) Runnable
b) Thread
c) Observer
d) ThreadCount
Clarification: None.
a) java.lang
b) java.io
c) java.util.zip
d) java.util.zar
Clarification: None.