View RSS Feed

Java Object

Abstract Methods

Rate this Entry
by , 04-26-2012 at 07:01 PM (612 Views)
If you desire a particular method to be present in a class and actual methodís implementation be determined by the help of a child class then you must be declaring methods which are present in parent class, as an abstract.
A method to be declard as an abstract, abstract keyword is being used. There is no method body in abstract method but do have a method signature.
Signatures of abstract methods are followed by semicolon and they have no definition:
Java Code:
public abstract class Employee
{
   private String name;
   private String address;
   private int number;
   
   public abstract double computePay();
   
   //Remainder of class definition
}
It would be resulting into things by declaration of method, as an abstract.

  • It is must for class to get declared as abstract. If abstract method is present in a class then it is also necessary for class to be abstract.
  • Child class shall either declare to be an abstract or shall be overriding the abstract method.

Submit "Abstract Methods" to Facebook Submit "Abstract Methods" to Digg Submit "Abstract Methods" to del.icio.us Submit "Abstract Methods" to StumbleUpon Submit "Abstract Methods" to Google

Categories
Polymorphism

Comments