I need one real time example so as to why i need to override equals and hashCode function.thanks for your early reply.
You need to override these methods whenever you stored your object in a collection like HashSet or HashMap.
These collections classes depend on the fact that the objects that you put as a key in them must obey the hashCode and equal contract. You will get strange and unpredictable results at runtime if you do not obey the contract and try to store them in a collection.
Also see [http://java.dzone.com/articles/java-hashing|http://java.dzone.com/articles/java-hashing]