• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

MindQ's #28 - Another bad (ambiguous) question  RSS feed

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
28. What exception might a wait() method throw?
The first answer that comes to my mind is IllegalMonitorStateException. The "correct" answer
is InterruptedException.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The signature of wait()in JLS clearly shows that wait()method throws both IllegalMonitorStateException and InterruptedException so IMO both IllegalMonitorStateException and InterruptedException are valid answers.
Regds,
Milind

[This message has been edited by Milind (edited April 02, 2000).]
[This message has been edited by Milind (edited April 02, 2000).]
 
Betty Reynolds
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right. This is one of those fill in the blank questions. IMO either answer is correct also, but you get penalized if you don't select InterruptedException. A better way to state this question would be to ask what checked exception might
wait() throw.
 
You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad?
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!