Page 683 - Computer science 868 Class 12
P. 683
Question 10:
A superclass Number is defined to calculate the factorial of a number. Define a subclass Series to find the sum of the series S = 1! + 2! +
3! + 4! + The details of the members of both the classes are given below:
Class name : Number
Data members/instance variables:
n : to store an integer number.
Member functions/methods:
Number(int num) : parameterised constructor to initialize the data member n = num.
int factorial (int a) : returns the factorial of a number (factorial of n = 1 × 2 × 3 × ... × n).
void display() : displays the data member
Class name : Series
Data members/instance variables:
sum : to store the sum of the series.
Member functions/methods:
Series(...) : parameterised constructor to initialise the data members of both the
classes.
void calSum() : calculates the sum of the given series.
void display() : displays the data members of both the classes.
Assume that the superclass Number has been defined. Using the concept of inheritance, specify the class Series giving details of the
constructor, void calSum() and void display().
Question 11:
2
i) What is the difference between O(N) and O(N ) [2]
ii) Answer the following questions from the diagram of a Binary Tree given below:
A
H J
C F K
D G L
E H
(a) The root of the tree. [1]
(b) Left subtree under H [1]
(c) Inorder traversal of the tree [1]
681
ISC Specimen Question Paper 681

