File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Mock Exam Errata and the fly likes errata for K&S SCJP Chapter 7 question 11 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "errata for K&S SCJP Chapter 7 question 11" Watch "errata for K&S SCJP Chapter 7 question 11" New topic
Author

errata for K&S SCJP Chapter 7 question 11

Jozsef Hegedus
Greenhorn

Joined: Oct 24, 2013
Posts: 1
Hi,

Is this erroneous?

Given:


And these two fragments:
I. public int hashCode() { return size/5; }
II. // no hashCode method declared
If fragment I or II is inserted, independently, at line 8, which are true? (Choose all that apply.)
A. If fragment I is inserted, the output is 2
B. If fragment I is inserted, the output is 3
C. If fragment II is inserted, the output is 2
D. If fragment II is inserted, the output is 3
E. If fragment I is inserted, compilation fails
F. If fragment II is inserted, compilation fails

My problem is that what happens if the two Turtle(1) objects end up in the same bucket? That would be hypothetically possible. Right?
(Because you cannot uniquely map 2^32 numbers to the number of buckets (as there are usually less number of buckets than 2^32).
What would happen then ? So for code fragment II. the result depends on the actual memory location of the two Turtle(1) objects (on
which the hash code values depend).

Cheers

Jozsef
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: errata for K&S SCJP Chapter 7 question 11
 
Similar Threads
hashcodes
collections.sort compiler error?
generics and collections: Q11, page 642 - is my understanding correct ?
Collections
Regarding Hashcode