🎴 Flashcard Mode
Programming in Java
Card1 / 5
Mastered0
Review0
QuestionClick to flip
What is the output?
class sample4 extends Thread {
public static void main(String[] args) {
new sample4().start();
}
public void run() {
try {
System.out.println("Starting to wait");
wait(1000);
System.out.println("Done waiting, returning back");
}
catch(InterruptedException e) {
System.out.println("InterruptedException Found");
}
catch(Exception e) {
System.out.println("Exception found");
}
}
}
AnswerClick to flip back
A
Starting to waitException found
💡 Explanation:
Correct choice
The wait() method calls without lock so it causes IllegalMonitorStateException, which catch block finds Exception.