MENU
Question -

Observe the following C++ code and answer the questions (i) and (ii). Assume all necessary files are included.   

class FICTION
{
long FCode; 
char FTitle [20]; 
float FPrice;
Public:
FICTION()
//Member Function 1
{
cout < <"Bought"< < endl;
FCode=100;strcpy(FTitle,"Noname ");FPrice=50;
}
FICTION(int C, char T[], float P) //Member Function 2
{
FCode=C;
strcpy(FTitle,T);
FPrice=P;
}
void Increase(float P) //Member Function 3
{
FPrice+=P;
}
void Show()
//Member Function 4
{
cout<
}
~FICTION ( ) //Member Function 5
}
};
void    main()                       //Line 1
{                                    //Line 2
FICTION FI, F2(101,"Dare",75);      // Line 3
for    (int 1=0;I<4;I++)            //Line  4
{                                   //Line  5
F1.Increase(2 0);F2.
Increase(15);                       //Line 6   
FI.Show();                          //Line 7
F2.Show()                           //Line 8
}                                   //Line 9
(i) Which specific concept of object oriented programming out of the following is illustrated by Member Function 1 and Member Function 2 combined together ?
> Data Encapsulation
> Data Hiding
> Polymorphism
> Inheritance
(ii) How many times the message “Fiction removed!” will be display ed after executing the above C + + code ? Out of Line 1 to Line 9, which line is responsible to display the message “Fiction removed! ” ?



Answer -

(i) Polymorphism    1
(ii) 2 times    1
Line 9.    1

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×