Posts

Showing posts from July, 2016

INTERVIEW QUESTION(JAVA)

VERY IMPORTANT INTERVIEW QUESTION(JAVA) Why CompareTo() has one parameter and Compare() has two parameters? Ans= ComapreTo() method will be implemented in the same adding object class. So among two objects one object is send as current object, another object is sent as argument object. Hence CompareTo() method has only one parameter. Compare() method will be implemented in the other class, not in adding object class. So the two object must be passed as argument. Hence compare() method has two parameters.

When java does not support pointers why does it throws NullPointerException?

When java does not support pointers why does it throws NullPointerException? Ans = When we call method on reference variable that holds null then there is a possibility of getting NullPointerException. Here the word pointer is no way related to c,c++ pointers it is used purely by having dictionary meaning say indicating method is invoked on reference variable that points to null value.