MY mENU


Thursday, 9 February 2012

Abstract class in java

Abstract Class : It can have without or with one or more Abstract Methods, have Concrete Methods (method with body implementation) and instance variables.

- We should declare Abstract Methods and Abstract Classes with the keyword abstract.

- We should implement all the Abstract Methods of Abstract Class in SubClass. In case if we not implement any one of Abstract Method in our SubClass we must and should declare our SubClass also as abstract.

Example :

abstract Class Manipulation{
int a,b;

/**** abstract method *****/
abstarct int calculate(int x, int y);


/**** concrete method *****/
int mul(int x, int y)
{
return (x * y);
}

}

No comments:

Post a Comment