O'Reilly logo

Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition by Rolf W. Rasmussen, Khalid A. Mughal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Review Questions

11.14 Given that the objects denoted by the parameters override the equals() and the hashCode() methods appropriately, which return values are possible from the following method?
String func(Object x, Object y) {
    return (x == y) + " " + x.equals(y) + " " + (x.hashCode() == y.hashCode());
}

Select the two correct answers.

  1. "false false true"

  2. "false true false"

  3. "false true true"

  4. "true false false"

  5. "true false true"

11.15 Insert code into the equalsImpl() method in order to provide a correct implementation of the equals() method.
 public class Pair { int a, b; public Pair(int a, int b) { this.a = a; this.b = b; } public boolean equals(Object ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required