A method declared as final can't be overridden. A sub-class can't have the same method signature with a different implementation.
When do you override hashcode and equals() ?
HashCode method return int value. So the Hash value is the int value returned by the hash function .
If you want to do equality check or want to use your object as key in HashMap, we must override hashcode and equals() method.
Which of these class have only one field 'TYPE' ?
The Void class has one field, TYPE, which holds a reference to the Class object for the type void.
What is the string contained in s after following lines of code?
StringBuffer s = new StringBuffer(“Hello”); s.deleteCharAt(0); ?
deleteCharAt() method deletes the character at the specified index location and returns the resulting StringBuffer object.
So after deleting the character at 0 ie 'H', the string returns 'ello' as the output.
Which of the following are incorrect form of StringBuffer class constructor ?
Does not overriding hashcode() method has any performance implication ?
A poor Hashcode() function will result in frequent collision in HashMap which eventually increase time for adding an object into Hash Map.
We'll send you weekly updates from Sawaal
Copyright © 2016 Sawaal.com | All Rights Reserved