Abstract Class:
================
Abstract Class are declared using the keyword abstract
Methods: In java they are two types of methods- add,main,subtract
a. concrete methods
b. abstract methods
a. Concrete Methods:- Methods which are having body are called as Concrete Methods
//Concrete Method or complete Method
public int add(int a,int b)
{
//Method body
}
If a method has curly braces mean, it has body and it is implemented.
b. Abstract Methods- Methods which are not having body are called as Abstract Methods
//Abstract Method or In-Complete Method
public abstract int add(int a, int b);
Points to be Noted for Abstract classes:
----------------------------------------
1. The abstract method should be declared with keyword abstract.
//In-complete Class
public abstract class Car
{
//Concrete Method
public void gears()
{
}
public abstract void engine();
}
2. If a class contains one abstract method, then the class should be declared as abstract.
3. Inside a abstract class, we can develop both abstract and concrete method.
Ex: abstract - engine,concrete-brakes()
4. If a class is declared as abstract its not mandatory to develop abstract methods.
5. We cannot create an instance/object of abstract class, hence we cannot
access non-static members of the abstract class.-Ex: we cannot invoke wheeling
6. The static members of the abstract class can be referred using class name.
Ex: By.name(""),By.className("")
non-static at the object level.
static at the class level.
7. A Sub-class inheriting an abstract class should override all the abstract
methods of abstract class. Ex: engine
In Subclass we have to provide implementations for all the abstract methods available
in the Super class which is abstract.