What is the result of the following code execution?

Integer i = 5000;
System.out.println(i.hashCode());
Explanation
Taken from the Integer.class source code:

/**
 * Returns a hash code for this {@code Integer}.
 *
 * @return  a hash code value for this object, equal to the
 *          primitive {@code int} value represented by this
 *          {@code Integer} object.
 */
public int hashCode() {
    return value;
}
Where value is the value of the integer.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes