This example shows how a simple java abstract class works
Here “Shape” is the abstract class
abstract class Shape{abstract void initial(); // methods only defined…..abstract void display();}class cube extends Shape{void initial() // Abstract Methods defined….{System.out.println(“Hello !! “);}void display(){System.out.println(“How are you?”);}}public class Abstract{public static void main(String[] args){// Shape S = new Shape(); // error cannot create objects for abstrac classes…..cube C = new cube();C.initial();C.display();}}
Here we cannot create “Shape” class object because it is abstract
The output is
Hello !!How are you?