Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Objects and Collections Questions
In Java, what does this code print when an anonymous class overrides hashCode()? public static void main(String[] args) { Object obj = new Object() { public int hashCode() { return 42; } }; System.out.println(obj.hashCode()); }
Java equality vs hashing: For two instances of the same class with properly overridden equals() and hashCode(), which statements are logically correct?
Given properly implemented equals() and hashCode(), the code prints "x = 1111". Which statement must always be true? x = 0; if (x1.hashCode() != x2.hashCode()) x = x + 1; if (x3.equals(x4)) x = x + 10; if (!x5.equals(x6)) x = x + 100; if (x7.hashCode() == x8.hashCode()) x = x + 1000; System.out.println("x = " + x);
Choosing the correct facts about properly overridden hashCode() and equals(): which two statements are valid in Java?
Java Collections Framework: Which statement accurately describes java.util.HashSet?
Iterator vs. ListIterator in Java: Which statements are correct about their capabilities and APIs?
Java Collections Framework: Which statement accurately describes java.util.ArrayList?
Which statements about the hashCode() method are incorrect for Java types?
Considering these two classes, which statement is true? class Test1 { public int value; public int hashCode() { return 42; } } class Test2 { public int value; public int hashcode() { return (int)(value ^ 5); } }
1
2