II B.Tech II Sem CSE Java Lab Exercise - 5a (Inheritance)

a)Implementing Single Inheritance

Aim: To write a JAVA program to implement Single Inheritance

Description:




Program:

class Shape 
{
    int length;
    int breadth;
}
class Rectangle extends Shape
{
    int area;
    public void calcualteArea()
    {
        area = length*breadth;
    }
    public static void main(String args[])
    {
        Rectangle r = new Rectangle();
        r.length = 10;
        r.breadth = 20;
        r.calcualteArea();
        System.out.println("The Area of rectangle of length \""
                +r.length+"\" and breadth \""+r.breadth+"\" is \""+r.area+"\"");
    }
}

Output:


No comments

File Uploading in PHP

  File Uploading in PHP PHP allow you to upload any type of a file i.e. image, binary or text files.etc..,PHP has one in built global variab...