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