What is Abstract class?
Abstract class consists of complete as well as incomplete methods.In simple words abstract class is 0 to 100% incomplete. And there should be keyword abstract to make method incomplete.
For Example:
abstract class A{
public abstract void test();
public void xyz(){
System.out.println(“Complete method”);
}
public static void main(){
}
As shown in above example we can create main method in this. Same as interface, we does not create an object. Unlike interface, there is no by default public access specifier. Similarly, variable is not by default public, final and static.
Similarly as interface, we have to override the incomplete in class to complete it.
For example:
abstract class A{
public abstract void test();
}
class B extends A{
public void test(){
System.out.println(” from abstract”);
}
public static void main(){
B b = new B();
b.test();
} }
Output: from abstract
In interface we were not able to create constructor because of not creating an object. But here we can create an constructor and instead of making object we can call constructor using super keyword.