Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Victoria Holland
Victoria Holland
6,159 Points

Which of these sets of hashcodes should not be possible?

In one of the quizzes in the Java Inheritance unit, I was faced with this question:

"Which of these sets of hashcodes should not be possible?"

The answer turned out to be "4, 11, 7, 4, 10" but it was just a lucky guess. Can someone please explain why that set of hashcodes isn't possible?

4 Answers

Steven Parker
Steven Parker
231,248 Points

A requirement of hashcodes is that they must all be unique, and in that list the number "4" occurs two times.

Pratham Mishra
Pratham Mishra
14,191 Points

can you elaborate? I didn't get what u said. What do mean by the term 'unique' exactly

Steven Parker
Steven Parker
231,248 Points

The term "unique" means that each one of them must be different from all the others.

Pratham Mishra
Pratham Mishra
14,191 Points

If that's the case, then the option '1,2,3,4,5' should also be valid right? And the rest of the answers should also be valid likewise.

Steven Parker
Steven Parker
231,248 Points

The question asks which one "should not be possible". So all the valid ones are wrong answers.

Pratham Mishra
Pratham Mishra
14,191 Points

oh, got it! Thank you for clearing the doubt

This question was really random. It confused me too.

I have no idea why they just say "Bummer! Your answer is incorrect." and not explain why, this quiz style is terrible. We are here to learn, not be graded, you can't redo the question unless you click away from it and then click back into the quiz.