Q. What is the result of the following program?

Code:
public static synchronized void main(String[] args) throws  
InterruptedException {  
     Thread f = new Thread();  
      f.start();  
      System.out.print("A");  
      f.wait(1000);  
      System.out.print("B");  
}
  • (A) It only prints A and exits
  • (B) It prints A and B with a 1000 seconds delay between them
  • (C) A will be printed, and then an exception is thrown.
  • (D) It only prints B and exits
πŸ’¬ Discuss
βœ… Correct Answer: (C) A will be printed, and then an exception is thrown.

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
232
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Vishal Gupta
Publisher
πŸ“ˆ
98%
Success Rate