- A method which has only method declaration and no definition is called as "Abstract method".
- Abstract method should be always declared with "abstract" keyword.
- A class which is declared with "abstract" keyword is called as abstract class.
ex: abstract class Vijay{
abstract public void blog();
}
- A method which has both method declaration and definition is called "concrete method".
- Class which contains only concrete methods is called as "contact class".
An abstract class may contain
(i) concrete methods
(ii)abstract methods
(iii) both concrete and abstract methods
- It is not possible to create object of an abstract class because the method don't have body or definition.
- We can create reference variable of an abstract class, because to perform upcasting and downcasting for achieving runtime polymorphism.
ex: Vijay v;
- If a class is extending an abstract class then the subclass should override the abstract methods present in abstract class.
- If a class is not overriding the abstract methods of superclass then the subclass also becomes abstract.
- Abstract methods cannot be declared as static.
- Abstract methods cannot be declared as private.
- Abstract methods cannot be declared as final because we can inherit final methods but we can't override it.
No comments:
Post a Comment