Sunday, 18 December 2022

Single inheritance

 Write a program using single inheritance which Is base class is shape and derived class is circle and calculate the area of circle



class shape
{
    public void area()
    {
        System.out.println("Display area");
    }

}
class cirle extends shape
{
    public void area (float r)
    {
       
        System.out.println(3.14*r*r);
    }

}
public class singleinheritance
{
    public static void main (String args [])
    {
        cirle t = new cirle();
        t.area(5);
    }
}








OUTPUT: 78.5


No comments:

Post a Comment

GitHub Most Imp Command For Every Developer Learn:

 Top Command for GitHub:  1) git clone 2) git init and git status   3) git add file name  or git add .  4) git commit -m message  5) git rem...