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
Ask questionWrite a program BruteForceSearch that uses the brute-force approach given above and compare its running time on your computer with that of Binary Search for largeW.txt

The Web container is used for managing the servlet's life cycle. The Web container produces an instance of the servlet and then the container invokes the init() function. At the co

write a program to find the area under thecurve y=f(x)between x=a and x=b, integrate y=f(x) between the limits of a and b. the area under a curve between two points can be found by

What is the role of fonts in java explain with example? You've already seen one instance of drawing text in the HelloWorldApplet program of the last chapter. You call the drawS

What is a local, member and a class variable? Variables declared within a method are "local" variables. Variables declared within the class i.e not within any methods are "m

This assignment has two main objectives. It aims to establish a basic familiarity with the Java API (Java Thread class) for creating multithreaded Java application, and the Java ne

I need to know waht exactly is happining in the following code class Worker implements Runnable { DatagramSocket socket = null; DatagramPacket packet = null; public W

What is the use of throws keyword ? Rather than explicitly catching an exception you can declare in which your method throws the exception. This passes the repsonsibility to h

RMI is a set of APIs that permits to build distributed applications. RMI uses interfaces to describe remote objects to turn local method invocations into remote method invocations.

What is an Applets? Applets: These are small java programs. They can send from one to another computer over internet by using Applet Viewer which supports java. Applets