This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes some odd answers from the K&B CD - part 3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "some odd answers from the K&B CD - part 3" Watch "some odd answers from the K&B CD - part 3" New topic
Author

some odd answers from the K&B CD - part 3

John Schubert
Ranch Hand

Joined: Sep 21, 2011
Posts: 39

Another cup of my favourite answers! This is question #53 from the first exam in K&B's CD.
The question presents a series of conditions over some object instances of unknow type, named x1, x2, x3, x4, x5 and x6. I'll skip the irrelevant stuff and post an equivalent question:


Given:
...
x5.equals(x6) == true
...

Which of the following statements will always be true? (Choose all that apply):
...
x5.hashCode() == x6.hashCode()
...


That answer was considered the correct and the others were all incorrect. But either the question is formulated wrongly or the answer is not correct.

We can clearly have a class where two equal objects have different hashCodes:



So the question should have rather been: "Which, according to the hashCode contract, should be always true?".Some questions are extremely picky on its language and others are leaving so much up to supposition. Not fair!
dennis deems
Ranch Hand

Joined: Mar 12, 2011
Posts: 808
John Schubert wrote:So the question should have rather been: "Which, according to the hashCode contract, should be always true?".Some questions are extremely picky on its language and others are leaving so much up to supposition. Not fair!


I have to tell you, it is very reassuring to see someone else expressing the reactions I had after taking the mock exams. If it helps, I don't remember anything on the exam even remotely approaching the level of ambiguity we find in some of the mock questions.
John Schubert
Ranch Hand

Joined: Sep 21, 2011
Posts: 39

Dennis Deems wrote:If it helps, I don't remember anything on the exam even remotely approaching the level of ambiguity we find in some of the mock questions.


It helps
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8801
    
    5
Hi Guys,

On the one hand, I think the question should be worded better...

On the other hand, I think you're going overboard a bit. In the old days the real exam might have tried to "trick" you like that, but it's just not that way any more. The exam does sometimes focus on important details, but not in a "tricky" way. Perhaps you've looked at other mock exams that rely on tricks? The real exam focuses on important stuff, it doesn't rely on tricks.

hth,

Bert


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: some odd answers from the K&B CD - part 3
 
Similar Threads
master exam doubt
LearnKey Bonus Exam question
hashcode & equals question
HashCode and Equals Contract Question from Master Exam Learner Key
Mock doubt, a Q about equals contract