Anu Bhagat wrote:Hi,
doSleep() method is a static method. why it is possible to call it from run ( non static method.)
Why is it impossible? We can always call static method from non-static context right? But the other way around - calling non-static from static context is not possible!
I think you got confused with static modifier; understand that static members are class properties which are loaded by the JVM when the class is loaded; but instance members are loaded only when an instance is created. So by the time an instance is instantiated, its static members would be in place right? So no problem calling them by static members right?
One class member is shared among all instances of class.
If class method want to call instance method then class member need to know object reference to call instance method of particular object. Without object reference class method doesn't know which instance method to call.