Kendriya Vidyalaya Abohar

Kendriya Vidyalaya Abohar

KENDRIYA VIDYALAYA No.5 BATHINDA CANTT

Summer Vacation Homework foe class –XII Comp. Sc.

Note:- There are two set of question papers. Students will solve the entire question paper in their notebook and submit on 20-06-2016.

SET-I

  1. What do you mean by static data member of a class? Explain the characteristics of a static data member. 2
  2. A class called A is declared and all its data members and member functions are private. Is it possible to declare and object of type A and use it in any function? Justify your answer. 2
  3. What is copy constructor? What do you understand by constructor overloading? 2
  4. Write a program to display the message “Learning C++” without calling a function and without writing a single cout statement in main. 2
  5. What is the difference between multiple and multilevel inheritance?2
  6. Distinguish between the following two statements:2

a) time T1(13, 10, 25); //statement 1

b) time T1 = time(13,10,25); //statement

  1. What are the advantages and disadvantages of inline functions?2
  2. Rewrite the following C++ program code after removing the syntax error(s) if any. Underline each correction. 3

# include(iostream.h)

Class TRAIN

{

Long TrainNo;

Char Description[25];

Public

Void Entry(){

Cin>TrainNo;gets(Description);

}

Void Display(){

Cout<TrainNo<”:”<Description<endl;}

};

Void main(){

TRAIN T;

Entry .T();

Display.T();}

  1. Describe the methods of accessing data members and member functions of a class in the following cases: 3

a) Inside the main program

b) Inside a member function of the same class

c) Inside a member function of another class.

  1. What do you understand by function overloading? Give an example illustrating its use in a C++ program. 4
  1. Write a function in C++ to find the sum of the following series:4

1+2+3+4+5+6+7+………. upto n terms.

  1. Define the following:4

a) Default Constructor

b) Copy Constructor

  1. Given the following C++ code, answer the questions i and ii:2

class readbook
{
public:
readbook( ) { //Function1
cout<”Open the Book”<endl;
}
void readchapter( ) { //Function 2
cout<”Reading chapter one”<endl;
}
~readbook( ) { //Function 3
cout<”Close the book”<endl;
}
};

a) In OOP, what is Function1 referred as and when does it get invoked/called?

b) In OOP, what is Function3 referred as and when does it get invoked/called?

  1. Declare a class to represent bank account of 10 customers with the following data members. Name the depositor, Account number, Type of account( S for Saving and C for Current), balance amount. The class also contains member functions to do the following: 6

a) To initialize data members

b) To deposit money

c) To withdraw money after checking the balance (minimum balance is Rs. 1000)

d) To display the data members

SET-II

  1. Write a program to count the no. of vowels in a given line of text.
  2. What is the difference between object oriented programming and procedural programming?
  3. How does OOP overcome the shortcomings of traditional programming approaches?
  4. Reusability of classes is one of the major properties of OOP. How is it implemented in C++?
  5. How is matching done in case of function overloading?
  6. When should default arguments be preferred over function overloading and vice-versa?
  7. When will you make a function inline and why?
  8. For which values of the variable ‘testnum’ will the following code become infinite:

int number=1, testnum;

cin>testnum;

while(1)

{ cout<number;

if (number==3)

break;

number+=testnum;

}

  1. Define a class Teacher with the following specification:

Private members:

  • Name20 Characters
  • Subject10 Characters
  • Basic, DA, HRAfloat
  • Salaryfloat
  • Calculate() function which computes the salary and returns it. Salary is sum of Basic, DA, and HRA. And also calculate DA as 57% of Basic and HRA as 30% of Basic.

Public members:

  • Constructor to assign Name as “Null”, Subject as English and Basic, DA, HRA, Salary as 0.0.
  • ReadData() function which accepts the data values and invoke the function Calculate().
  • DisplayData() function which prints the data on the screen.
  1. Define a class Housing with the following specification:
  2. Private members:
  3. Name20 Characters
  4. TypeCharacter
  5. Costfloat
  6. Reg_no integer (range 10-1000)
  7. Public members:
  • ReadData() function to read an object of Housing type.
  • DisplayData() function which prints the details of an object.
  • Function Draw_nos() to chose and display the details of two houses selected randomly from an array of ten objects of type Housing. Use random function to generate the registration numbers to match with Reg_no from the array.
  1. What do you mean by Polymorphism? Illustrate its example in C++.
  2. Answer the questions (i) to (iv) based on the following code :

class Capsule

{char Category[20];

char Date_of_manufacture[10];

char Company[25];

float cost;

public:

Capsule();

void entercapsuledetails( );

void showcapsuledetails( );

};

class Tablet

{protected:

char tablet_name[25];

char Volume_label[10];

public:

float Price;

Tablet();

void entertabletdetails( );

void showtabletdetails( );

};

class PainReliever : public Tablet, private Capsule

{int Dosage_units;

char Side_effects[20];

int Use_within_days;

public:

PainReliever();

void enterdetails( );

void showdetails( );

};

(i) How many bytes will be required by an object of class PainReliever ?

(ii) Write names of all the members which are accessible from the object of class PainReliever.

(iii) Write the name of the type of inheritance?

(iv) Write names of all the members which are accessible from member function class PainReliever.

(v) Write names of all the members of class Capsule which are accessible from member function of class PainReliever.

  1. Find the output of following code fragment:-

void main()

{int r, x, y, r1;

clrscr();

cout<”Enter any two Numbers :->”;

cin>x>y;

r=1; r1=0;

while (r!=0)

{r=x%y;

r1=y/x;

y=x;

x=r;

}

cout<”OUTPUT is:->”<r1;

}Suppose the inputs entered by the user are: -> 50, 75.

  1. Find out the errors if any, in the following code:-

#include<iostram.h>

void main()

{ int a,b,c;

c=div(a,b)

cout<c;

}

int div(int x, int y)

{x=x+y;

y=y+y;

retutn(x,y);

}

Do Summer Holiday Home work in H.W. Notebook and submit on 20th June 2016.