Originally posted by Ho Gong:
Is that true? Who can verify?
I always try to stress the fact that the
SCJP exam really emphasizes knowledge of the
Java syntax - not really knowledge of good programming techniques. For that, I'd recommend that you go on to the developer's certification.
In this case (except for the return value), the implementation given for the equals method is perfectly legitimate. Of course, this method is also legitimate:
That's legal code - it will compile (or should, at least - I didn't test it) and run. Of course, it probably won't do what you'd expect a equals method to do, but there's no reason you
couldn't use that as an equals method - it follows all the syntax rules of Java.
When you take the exam, you don't need to concern yourself if the code is "good" code, you really only need to concern yourself if the code will work.
I hope that helps,
Corey