More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Ans. Returning from inside a finally block will cause exceptions to be lost. A return statement inside a finally block will cause any exception that might be thrown in the try block to be discarded.
Help us improve. Please let us know the company, where you were asked this question :
Ans. final keyword is used to restrict the user from modifying the variable, extending the class and overriding a method
static keyword is used for memory management which can be used for variable, class, method where in it belongs to the class not to the instance of object
Help us improve. Please let us know the company, where you were asked this question :
Ans. "equals" method is the method of object class that needs to be overridden to check object equality. This is not specific to any class like String.
equalsignorecase is the method of String class that provides a definition that ignores the case of characters during comparison.
The only difference between them in String class is that the equals() methods considers the case while equalsIgnoreCase() methods ignores the case during comparison.
Help us improve. Please let us know the company, where you were asked this question :
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality. x.equals(y) means the references x and y are holding objects that are equal with the equality defined by the definition of equals method.
Hashcode is used for bucketing in Hash implementations like HashMap, HashTable, HashSet etc. The value received from hashcode() is used as bucket number for storing elements. This bucket number is the address of the element inside the set/map. when you do contains() then it will take the hashcode of the element, then look for the bucket where hashcode points to and if more than 1 element is found in the same bucket (multiple objects can have the same hashcode) then it uses the equals() method to evaluate if object are equal, and then decide if contain() is true or false, or decide if element could be added in the set or not.
Help us improve. Please let us know the company, where you were asked this question :
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality. x.equals(y) means the references x and y are holding objects that are equal.
The compareTo() method is used for comparing two objects in Java. It is usually defined for the classes whose objects needs to be ordered through Comparable interface or need to be part of an ordered collection like TreeSet or TreeMap.
Help us improve. Please let us know the company, where you were asked this question :