Non-final functions in java object class, JAVA Programming

clone (), finalize (), toString (), equals (), hashCode () and. The other methods like wait (), getClass (), notifyAll (), notify ()

toString():

 The toString() function given by the java.lang.Object returns a string, which consists of the class name followed by an "@" sign and then unsigned hexadecimal presentation of the hashcode, As Set@162b91. This hexadecimal presentation is not what the users of your class want to see.

 

clone():

 

You have to override the clone() method very judiciously. Implementing a properly working clone method is complex and it is rarely used. You are better off providing some alternative defines of object copying or simply not giving the capability. A better approach is to give a copy constructor or a static factory function in place of a constructor.

 

finalize():

 

Unlike C++ destructors, the finalize() method in Java is unpredictable,  dangerous and usually unnecessary. Use try{} finally{} blocks in Enterprise section. The finalize() method could only be need in rare instances to terminate non-critical native resources or as a safety net.

protected void finalize() throws Throwable {

try{

//finalize subclass state

}

finally {

super.finalize();

}

}

 

Posted Date: 7/25/2012 1:58:17 AM | Location : United States







Related Discussions:- Non-final functions in java object class, Assignment Help, Ask Question on Non-final functions in java object class, Get Answer, Expert's Help, Non-final functions in java object class Discussions

Write discussion on Non-final functions in java object class
Your posts are moderated
Related Questions
Struts is a set of cooperating classes, servlets, and JSP tags that make up a reusable MVC 2 design. ? JavaBeans components for managing application state and behavior. ? Eve

What are application softwares? List down the names of three application software's. Definition: Application Software are in which software then can interact directory along

Write down HTML or JavaScript code for the following requirements: Declare an Array along with the identifier SUBJECT having length 5. Assign subsequent values to the array par


If there exist multiple conditions, the switch statement is suggested. It is because only one expression gets evaluated depending on which control jumps directly to the respective

Explain Testing Objects for Equality in java? , = can only be used with numbers and characters. They cannot be used with Strings, booleans, arrays or other compound types sin


I have been working on my compiler''s parser now. And for some reason i cant make my parse tree printer to work. SyntaxTree keeps on showing as null when i invoke the print() metho

Task 1 Create a new project in Eclipse called Assignment 1. Within this project create a package called task01. 1/ Download the class Date (you must use this class - no

How many bits are we used in Unicode, ASCII, UTF-16, and UTF-8 characters?