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
Give an Examples of java.lang.Math Methods Here is an instance program in which exercises most of the routines in java.lang.Math. If your high school math is a little rusty, do


Custom Website Technical Specification Document A Solution provider / System Architect to interpret and speak with me and build business functional needs and a set of research d

I am preparing ehopsital project. For the needs of hospital in that billing module and patient registration and stores module and e.t.c module is there for hospital needs. Skill

How can I connect my java application with xampp

What is linear search? It is the simplest form of search. It searches for the element sequentially starting from first element. This search has a drawback if element is located

Write a program that prompts for two people’s birthdays (month and day), along with today’s month and day. The program should figure out how many days remain until each user’s birt

Please submit your answers     In this homework, we are going to generate Java Virtual Machine codes by processing the abstract syntax tree constructed from the parsing process

What is Methods in java explain with an example? Data types aren't much use unless you can do things along with them. For this reasons classes have techniques. Fields say what

Describe Overriding Methods ? Assume that one day you've just finished your Car class. It's been plugged into your traffic simulation that is chugging along merrily simulating