Why sleep()is in Thread and wait() in Object class? Why can't
I have both in one class or vice versa?
In Java "Object" class is super for all classes and every
entity we consider as object in java. Every object in java
has default behaviour of "Object" class.
Now come to the point, When you instantiate a thread you
may require to stop a while that particular thread.So
Thread class has sleep method.
But in the situation of multithreading, you may require wait
() and notify() methods so that you can invoke "Object"
class behavior to your class.
| Is This Answer Correct ? | 7 Yes | 3 No |
Which methods cannot be overridden in java?
What is an empirical question?
What is the difference between jdk, jre, and jvm?
Can long be null in java?
What exactly is java?
Can a static member function access member variable of an object?
What is jvm? Why is java called the platform independent programming language?
Java run-time system generates What class of exceptions?
Can we declare an anonymous class as both extending a class and implementing an interface?
8 Answers College School Exams Tests, JVA, TCS, Wipro,
Can java cast null?
What is a function in programming?
What do you mean by ternary operator in java?