Welcome! Log In Create A New Profile


Tut 102 Question3

Posted by ToKnowOrNotToKnow 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Tut 102 Question3
October 13, 2006 06:07PM
This question asks what the output will be of

ReadingMaterial a = new ReadinMaterial();

Can anyone help with the answer? What I can see is that it will print the HashCode and not the address of the object.

confused smiley
Re: Tut 102 Question3
October 22, 2006 11:16AM
You are correct


Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

getClass().getName() + '@' + Integer.toHexString(hashCode())

Re: Tut 102 Question3
October 23, 2006 03:51PM
Hmm... interesting info there. Nice to learn something new here in the forums.
Re: Tut 102 Question3
October 24, 2006 07:25PM
Here is the answer from the lecturers:

The option that is partially correct is 4 but as you said it is not completely correct. The hashCode() method returns the hashcode of the object which is the object's memory address in hexadecimal .Refer to http://java.sun.com/docs/books/tutorial/java/IandI/objectclass.html
You can ignore this question.

A. Thomas
Sorry, only registered users may post in this forum.

Click here to login