Important Questions

CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By Ravi Kiran

CBSE CLASS XII

2. (a) Define the term Data Hiding in the context of Object Oriented Programming. Give a
suitable example using a C++ code to illustrate the same. 2

(b) Answer the questions (i) and (ii) after going through the following class: 2
class Test
{
char Paper[20];
int Marks;
public:
Test() // Function 1
{
strcpy(Paper, “Computer”)
Marks = 0;
}
Test(char P[] ) // Function 2
{
strcpy(Paper,P);
Marks = 0;
}
Test(int M) // Function 3
{
strcpy(Paper,”Computer”);
Marks = M;
}
Test(char P[], int M) // Function 4
{
strcpy(Paper, P);
Marks = M;
}
};

(i) Which feature of Object Oriented Programming is demonstrated using Function 1, Function 2, Function 3 and Function 4 in the above class Test?

(ii) Write statements in C++ that would execute Function 2 and Function 4 of class Test.

(c) Define a class TravelPlan in C++ with the following descriptions : 4
Private Members:
PlanCode of type long
Place of type character array (string)
Number_of_travellers of type integer
Number_of_buses of type integer
Public Members:
A constructor to assign initial values of Plan Code as 1001, Place as “Agra”,
Number_of_travellers as 5, Number_of_buses as 1
A function NewPlan( ) which allows user to enter PlanCode, Place and
Number_of_travellers. Also, assign the value of Number_of_buses as per the
following conditions :

Number_of_travellers Number_of_buses
Less than 20 1
Equal to or more than 20 and less than 40 2
Equal to 40 or more than 40 3
A function ShowPlan( ) to display the content of all the data members on screen.

(d) Answer the questions (i) to (iv) based on the following code: 4
class Medicines
{
char Category[lO];
char Date_of_manufacture[lO];
char Company[20];
public:
Medicines();
void entermedicinedetails();
void showmedicinedetails();
} ;
class Capsules: public Medicines
{
protected:
char capsule_name[30];
char Volume_label[20];
public:
float Price;
Capsules();
void entercapsuledetails();
void showcapsuledetails();
};
class Antibiotics: public Capsule
{
int Dosage_units;
char Side_effects[20];
int Use_within_days;
public:
Antibiotics() ;
void enterdetails();
void showdetails();
};

(i) How many bytes will be required by an object of class Medicines and an object of class Antibiotics respectively?

(ii) Write names of all the member functions accessible from the object of class Antibiotics.

(iii) Write names of all the members accessible from member functions of class Capsules.

(iv) Write names of all the data members, which are accessible from objects of class Antibiotics.

Paper By Mr. Ravi Kiran
Email Id : [email protected]