250+ TOP MCQs on Observable & Timer Class and Answers

Java MCQs 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

Answer: b
Clarification: 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()

Answer: a
Clarification: None.

3. Which of these methods calls update() method?
a) notify()
b) observeObject()
c) updateObserver()
d) notifyObserver()

Answer: d
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().

4. Which of these methods is called when observed object has changed?
a) setChanged()
b) update()
c) notifyObserver()
d) all of the mentioned

Answer: d
Clarification: None.

5. Which of these classes can schedule task for execution in future?
a) Thread
b) Timer
c) System
d) Observer

Answer: b
Clarification: 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

Answer: a
Clarification: 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

Answer: c
Clarification: None.

Global Education & Learning Series – Java Programming Language.

Leave a Reply

Your email address will not be published. Required fields are marked *