In this tutorial, we are going to write a Java program using an abstract class in Java Programming with practical program code and step-by-step full complete explanation.

java program using abstract class


Java program using abstract class.

 
public abstract class shape
{
    public abstract void calculatearea();
}

public class circle extends shape
{
    privateintx,y;
    privateint radius;

    public circle()
    {
        x=15;
        y=15;
        radius=10;
    }

    public void calculatearea ()
    {
        double area=3.14*(radius*radius);

        System.out.println("area="+area);
    }
}

class test1
{
    public static void main(String arr[])
    {
        shape s =null;
        s=new circle();
        s.calculatearea();
    }
}


Output

 
area=314.0