1. What is inheritance? [2]
2. Convert the following infix expression to its postfix form. b*[(a/d) – (c * (e-f))] [2]
3. Explain the use of keyword “implements”, define interface. [2]
4. What is an abstract class? [2]
5. Write any two uses of inheritance. [2]
6. Give output of the following function where x and y are arguments greater than 0. Show the dry run/ working. [5]
int strange(int x , int y)
{ //Assuming x>0 y>0
return strange(x,y);
else return x;
What will the function strange(20,5) return ?
7. The following function Recur() is a part of some class. What will be the output of the function Recur() when the value of n is equal to 10. Show the dry run/working. [5]
public void Recur (int n)
System.out.print(n+” “);
if(n%2 !=0)
System.out.print(n+” “);
8. A super class Record has been defined to store the names and ranks of 50 students. Define a sub class Rank to find the highest rank along with the name. The details of both classes are given below:
Class name : Record
Data members
name[] : to store the names of students rnk[] : to store the ranks of students Member functions:
Record() : constructor to initialize data members void readvalues() : to store names and ranks
void display() : displays the names and the corresponding ranks

class name : Rank
Data members
index : integer to store the index of the topmost rank
Member functions
Rank() : constructor to invoke the base class constructor and to initialize index to 0.
void highest() : finds the index location of the topmost rank and stores it in index without sorting the array
void display() : displays the name and ranks along with the name having the topmost rank.
Specify the class Record giving details of the constructor(), void readvalues(), void display(). Using the concept of inheritance, specify the class Rank giving details of constructor(), void highest() and void display(). The main function and algorithm need not be written. [5]

9. A super class Detail has been defined to store the details of a customer. Define a sub-class Bill to compute the monthly telephone charge of the customer as per the chart given below:

Number of Calls Rate
1-100                                                             Only rental charge
101-200                                                         60 paisa per call + rental charge
201-300                                                         80 paisa per call+ rental charge
Above 300                                                      1 rupee per call + rental charge
The details of both the classes are given below:

Class name Detail
Data members
name to store the name of the customer
address to store the address of the customer
telno to store the phone number of the customer
rent to store the monthly rental charge
Member functions
Detail(…..) parameterized constructor
void show() to display the details of the customer

Class name Bill
Data members
n         to store the number of calls
amt      to store the amount to be paid by the customer
Member functions
Bill(…….) parameterized constructor
void cal() calculate the monthly telephone charge as per the chart given above.
void show() displays the details of the customer and amount to be paid.
Specify the above class using the concept of inheritance no need to define the main function. [5]


Please enter your comment!
Please enter your name here