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
Benefits of AOP (Aspect Oriented programming) OOP can give the system level code like transaction management, logging, security etc to scatter throughout the business logic. A

Fill in the necessary parts to create a GUI that uses the CardDeck class.  In your GUI you should have a text field for each hand, two buttons and a text area.   Your program s


Struts components can be classify into Model, View and Controller: ? Model: Components like business logic /business processes and data are the type of model. ? View: HTML, J

What are synchronized methods and synchronized statements? Synchronized methods are methods that are used to control access to an object. A thread only implements a synchronize

what are cookies?

#comparison of merge sort and bubble sort

Very frequently when you write code, you desire to perform distinct actions for different decisions. You can employ conditional statements in your code to do this. In JavaScript

There is no separate homework this week, but you may complete the exercises ahead of time, in which case you only need to attend for long enough to get your work marked off by your

Integration: Neo4J, OpenGeo, Ikanow Project Description: I have an ongoing project to loosely integrate a variety of existing Open Source products: OpenGeo (geospatial server