This section of our 1000+ Java MCQs focuses on Observable & Timer class of Java Programming Language.
1. What is the use of Observable class?
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
View Answer
Explanation: The Observable class is used to create subclasses that other part of program can observe.
2. Which of these methods is used to notify observer the change in observed object?
a) update()
b) notify()
c) check()
d) observed()
View Answer
Explanation: None.
3. Which of these methods calls update() method?
a) notify()
b) observeObject()
c) updateObserver()
d) notifyObserver()
View Answer
Explanation: 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().
4. Which of these methods is called when observed object has changed?
a) setChanged()
b) update()
c) notifyObserver()
d) all of the mentioned
View Answer
Explanation: None.
5. Which of these classes can schedule task for execution in future?
a) Thread
b) Timer
c) System
d) Observer
View Answer
Explanation: Timer and TimerTask are the classes that support the ability to schedule tasks for execution at some future time.
6. Which of these interfaces is implemented by TimerTask class?
a) Runnable
b) Thread
c) Observer
d) ThreadCount
View Answer
Explanation: None.
7. Which of these package provides the ability to read and write in Zip format?
a) java.lang
b) java.io
c) java.util.zip
d) java.util.zar
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series Java Programming Language.
- Practice Information Technology MCQs
- Check Programming Books
- Check Java Books
- Practice Programming MCQs
- Apply for Computer Science Internship