0

Someone asked me this question in an interview. I am not sure if it is a valid question or not. If it is please reply. Thanks

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
Priyanka Taneja
  • 515
  • 1
  • 5
  • 21
  • Can there be a situation where you want to "wait" on a specific instance of an object? Think about it... ;) – vikingsteve Dec 03 '19 at 09:39
  • 1
    Does this answer your question? [Concept behind putting wait(),notify() methods in Object class](https://stackoverflow.com/questions/17840397/concept-behind-putting-wait-notify-methods-in-object-class) – Sasikumar Murugesan Dec 03 '19 at 09:39
  • I just wonder which interview you were asked this question. – aydinugur Dec 03 '19 at 09:42

1 Answers1

6

java.lang.Class implictly extends java.lang.Object, like every other object type, so it inherits both this methods from Object:

Class<?> clazz = new Object().getClass();
clazz.wait();
Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111