Sunday , 22 July 2018
Home » Inheritance Related Programs » [Question 11 (Inheritance)] ISC 2013 (Theory) Paper Solved

[Question 11 (Inheritance)] ISC 2013 (Theory) Paper Solved


A super class Perimeter has been defined to calculate the perimeter of a parallelogram. Define a subclass Area to compute the area of the parallelogram by using the required data members of the super class. The details are given below:

Class name : Perimeter

Data members/instance variables:
a : to store the length in decimal
b : to store the breadth in decimal

Member functions:
Perimeter( … ) : parameterized constructor to assign values to data members
double Calculate( ) : calculate and return the perimeter of a parallelogram as 2 * (length + breadth)
void show() : to display the data members along with the perimeter of the parallelogram

Class name : Area

Data members/instance variables:
h : to store the height in decimal
area : to store the area of the parallelogram

Member functions:
Area( … ) : parameterized constructor to assign values to data members of both the classes
void doarea( ) : compute the area as (breadth * height)
void show() : display the data members of both classes along with the area and perimeter of the parallelogram.

Specify the class Perimeter giving details of the constructor( … ), void Calculate( ) and void show( ). Using the concept of inheritance, specify the class Area giving details of the constructor( … ), void doarea( ) and void show( ).

The main function and algorithm need not be written.

[Note: We will be writing the main() function also in this program so as to familiarize the students on how to run programs based on the concept of inheritance.]

Programming Code:

* The superclass Perimeter calculate the perimeter of a parallelogram and
* the subclass Area calculates the area of a parallelogram
* @author :
* @Program Type : BlueJ Program - Java
* @Question Year : ISC Theory 2013 Question 11

class Perimeter //superclass
        double a,b;
        Perimeter(double x, double y)
        double Calculate()
            double p=2*(a+b);
            return p;
        void show()
            System.out.println("Length = "+a);
            System.out.println("Breadth = "+b);
            System.out.println("Perimeter = "+Calculate()); //printing perimeter by calling Calculate()
    } //end of superclass Perimeter

class Area extends Perimeter //subclass
        double h, area;
        Area(double x, double y, double z)
            super(x,y); //initializing data members of superclass by calling its constructor
        void doarea()
        void show()
  ; //calling the superclass function show()
            System.out.println("Height = "+h);
            System.out.println("Area = "+area);
    } //end of subclass Area

/* In your exams you don't need to write the below given code
   We are writing it so as to familiarize the students on how to run
   programs based on the concept of inheritance.*/

public class Question11_ISC2013 //Class which will contain the main() method and execute the program
        public static void main(String args[])throws IOException
            BufferedReader br=new BufferedReader(new InputStreamReader(;
            System.out.print("Enter The Length : ");
            double x=Double.parseDouble(br.readLine());
            System.out.print("Enter The Breadth : ");
            double y=Double.parseDouble(br.readLine());
            System.out.print("Enter The Height : ");
            double z=Double.parseDouble(br.readLine());

            Area ob=new Area(x,y,z); //creating object of subclass
            System.out.println("*** Output ***");
  ; //calling show() function of subclass


Enter The Length : 5
Enter The Breadth : 7
Enter The Height : 9
*** Output ***
Length = 5.0
Breadth = 7.0
Perimeter = 24.0
Height = 9.0
Area = 63.0

Check Also

ISC 2017 Computer Science Solution + Examiner’s Comments – From the Council

Solution of ISC 2017 Computer science Paper as provided by the Council for the Indian School Certificate Examinations.

Leave a Reply

Your email address will not be published. Required fields are marked *