Tamil Nadu Board of Secondary EducationHSC Science Class 11

# Tamil Nadu Board Samacheer Kalvi solutions for Class 11th Computer Science Answers Guide chapter 15 - Polymorphism [Latest edition]

#### Chapters ## Solutions for Chapter 15: Polymorphism

Below listed, you can find solutions for Chapter 15 of Tamil Nadu Board of Secondary Education Tamil Nadu Board Samacheer Kalvi for Class 11th Computer Science Answers Guide.

Evaluation - Section - AEvaluation - Section - BEvaluation - Section - CEvaluation - Section - DCASE STUDY
Evaluation - Section - A [Pages 256 - 257]

### Tamil Nadu Board Samacheer Kalvi solutions for Class 11th Computer Science Answers Guide Chapter 15 Polymorphism Evaluation - Section - A [Pages 256 - 257]

Evaluation - Section - A | Q 1. | Page 256

Which of the following refers to a function having more than one distinct meaning?

Evaluation - Section - A | Q 2. | Page 256

Which of the following reduces the number of comparisons in a program?

Evaluation - Section - A | Q 3. | Page 256

void dispchar(char ch=’$’,int size=10) { for(int i=1;i<=size;i++) cout<<ch; } How will you invoke the function dispchar() for the following input? To print$ for 10 times

• dispchar();

• dispchar(ch,size);

• dispchar($,10); • dispchar(‘$’,10 times);

Evaluation - Section - A | Q 4. | Page 257

Which of the following is not true with respect to function overloading?

• The overloaded functions must differ in their signature.

• The destructor function cannot be overloaded.

Evaluation - Section - A | Q 5. | Page 257

• void fun (intx);
void fun (char ch) ;

• void fun (intx);
void fun (inty);

• void fun (double d);
void fun (char ch);

• void fun (double d);
void fun (inty);

Evaluation - Section - B [Page 257]

### Tamil Nadu Board Samacheer Kalvi solutions for Class 11th Computer Science Answers Guide Chapter 15 Polymorphism Evaluation - Section - B [Page 257]

Evaluation - Section - B | Q 1. | Page 257

Evaluation - Section - B | Q 2. | Page 257

List the operators that cannot be overloaded.

Evaluation - Section - B | Q 3. | Page 257

class add{int x; public: add(int)}; Write an outline definition for the constructor.

Evaluation - Section - B | Q 4. | Page 257

Does the return type of a function help in overloading a function?

Evaluation - Section - B | Q 5. | Page 257

Evaluation - Section - C [Page 257]

### Tamil Nadu Board Samacheer Kalvi solutions for Class 11th Computer Science Answers Guide Chapter 15 Polymorphism Evaluation - Section - C [Page 257]

Evaluation - Section - C | Q 1. | Page 257

Evaluation - Section - C | Q 2. | Page 257

How does a compiler decide as to which function should be invoked when there are many functions? Give an example.

Evaluation - Section - C | Q 3. | Page 257

Evaluation - Section - C | Q 4. | Page 257

Evaluation - Section - C | Q 5. | Page 257

class sale ( int cost, discount; public: sale(sale &); Write a non-inline definition for constructor specified;

Evaluation - Section - D [Pages 258 - 259]

### Tamil Nadu Board Samacheer Kalvi solutions for Class 11th Computer Science Answers Guide Chapter 15 Polymorphism Evaluation - Section - D [Pages 258 - 259]

#### Explain in detail

Evaluation - Section - D | Q 1. | Page 258

Evaluation - Section - D | Q 2. (i) | Page 258

Answer the question after going through the following class.

class Book {
int BookCode ; char Bookname;float fees;
public:
Book( )   //Function 1
{ fees=1000;
BookCode=1;
strcpy(Bookname,"C++"); }
void display(float C) //Function 2
{ cout<<BookCode<<":"<<Bookname<<":"<<fees<<endl; }
~Book( )         //Function 3
{ cout<<"End of Book Object"<<endl; }
Book (intSC,char S[ ],float F) ; //Function 4
};

In the above program, what are Function 1 and Function 4 combined together referred to as?

Evaluation - Section - D | Q 2. (ii) | Page 258

Answer the question after going through the following class.

class Book {
int BookCode ; char Bookname;float fees;
public:
Book( )   //Function 1
{ fees=1000;
BookCode=1;
strcpy(Bookname,"C++"); }
void display(float C) //Function 2
{ cout<<BookCode<<":"<<Bookname<<":"<<fees<<endl; }
~Book( )         //Function 3
{ cout<<"End of Book Object"<<endl; }
Book (intSC,char S[ ],float F) ; //Function 4
};

Which concept is illustrated by Function3? When is this function called/invoked?

Evaluation - Section - D | Q 2. (iii) | Page 258

Answer the question after going through the following class.

class Book {
int BookCode ; char Bookname;float fees;
public:
Book( )   //Function 1
{ fees=1000;
BookCode=1;
strcpy(Bookname,"C++"); }
void display(float C) //Function 2
{ cout<<BookCode<<":"<<Bookname<<":"<<fees<<endl; }
~Book( )         //Function 3
{ cout<<"End of Book Object"<<endl; }
Book (intSC,char S[ ],float F) ; //Function 4
};

What is the use of Function 3?

Evaluation - Section - D | Q 2. (iv) | Page 258

Answer the question after going through the following class.

class Book {
int BookCode ; char Bookname;float fees;
public:
Book( )   //Function 1
{ fees=1000;
BookCode=1;
strcpy(Bookname,"C++"); }
void display(float C) //Function 2
{ cout<<BookCode<<":"<<Bookname<<":"<<fees<<endl; }
~Book( )         //Function 3
{ cout<<"End of Book Object"<<endl; }
Book (intSC,char S[ ],float F) ; //Function 4
};

Write the statements in main to invoke function1 and function2?

Evaluation - Section - D | Q 2. (v) | Page 258

Answer the question after going through the following class.

class Book {
int BookCode ; char Bookname;float fees;
public:
Book( )   //Function 1
{ fees=1000;
BookCode=1;
strcpy(Bookname,"C++"); }
void display(float C) //Function 2
{ cout<<BookCode<<":"<<Bookname<<":"<<fees<<endl; }
~Book( )         //Function 3
{ cout<<"End of Book Object"<<endl; }
Book (intSC,char S[ ],float F) ; //Function 4
};

Write the definition for Function4.

Evaluation - Section - D | Q 3. | Page 258

Write the output of the following program.

include<iostream>
using namespace std;
class Seminar
{ int Time;
public:
Seminar()
{ Time=30;cout<<"Seminar starts now"<<endl; } void Lecture()
cout<<"Lectures in the seminar on"<<endl; } Seminar(int Duration)
{ Time=Duration;cout<<"Welcome to Seminar "<<endl; }
Seminar(Seminar &D)
{ Time=D.Time;cout<<"Recap of Previous Seminar Content "<<endl;}
~Seminar()
{cout<<"Vote of thanks"<<endl; } };
int main()
{ Seminar s1,s2(2),s3(s2);
s1.Lecture();
return 0;
}

Evaluation - Section - D | Q 4. (i) | Page 259

Answer the question based on the following program.

#include<iostream>
#include<string.h>
using namespace std;
class comp {
public:
char s;
void getstring(char str)
{ strcpy(s,str); }
void operator==(comp);
};
void comp::operator==(comp ob)
{ if(strcmp(s,ob.s)==0)
cout<<"\nStrings are Equal";
else
cout<<"\nStrings are not Equal"; }
int main()
{ comp ob, ob1;
char string1, string2;
cout<<"Enter First String:";
cin>>string1;
ob.getstring(string1);
cout<<"\nEnter Second String:";
cin>>string2;
ob1.getstring(string2);
ob==ob1;
return 0; }

Mention the objects which will have the scope till the end of the program.

Evaluation - Section - D | Q 4. (ii) | Page 259

Answer the question based on the following program.

#include<iostream>
#include<string.h>
using namespace std;
class comp {
public:
char s;
void getstring(char str)
{ strcpy(s,str); }
void operator==(comp);
};
void comp::operator==(comp ob)
{ if(strcmp(s,ob.s)==0)
cout<<"\nStrings are Equal";
else
cout<<"\nStrings are not Equal"; }
int main()
{ comp ob, ob1;
char string1, string2;
cout<<"Enter First String:";
cin>>string1;
ob.getstring(string1);
cout<<"\nEnter Second String:";
cin>>string2;
ob1.getstring(string2);
ob==ob1;
return 0; }

Name the object which gets destroyed in between the program.

Evaluation - Section - D | Q 4. (iii) | Page 259

Answer the question based on the following program.

#include<iostream>
#include<string.h>
using namespace std;
class comp {
public:
char s;
void getstring(char str)
{ strcpy(s,str); }
void operator==(comp);
};
void comp::operator==(comp ob)
{ if(strcmp(s,ob.s)==0)
cout<<"\nStrings are Equal";
else
cout<<"\nStrings are not Equal"; }
int main()
{ comp ob, ob1;
char string1, string2;
cout<<"Enter First String:";
cin>>string1;
ob.getstring(string1);
cout<<"\nEnter Second String:";
cin>>string2;
ob1.getstring(string2);
ob==ob1;
return 0; }

Name the operator which is overloaded and write the statement that invokes it.

Evaluation - Section - D | Q 4. (iv) | Page 259

Answer the question based on the following program.

#include<iostream>
#include<string.h>
using namespace std;
class comp {
public:
char s;
void getstring(char str)
{ strcpy(s,str); }
void operator==(comp);
};
void comp::operator==(comp ob)
{ if(strcmp(s,ob.s)==0)
cout<<"\nStrings are Equal";
else
cout<<"\nStrings are not Equal"; }
int main()
{ comp ob, ob1;
char string1, string2;
cout<<"Enter First String:";
cin>>string1;
ob.getstring(string1);
cout<<"\nEnter Second String:";
cin>>string2;
ob1.getstring(string2);
ob==ob1;
return 0; }

Write out the prototype of the overloaded member function.

Evaluation - Section - D | Q 4. (v) | Page 259

Answer the question based on the following program.

#include<iostream>
#include<string.h>
using namespace std;
class comp {
public:
char s;
void getstring(char str)
{ strcpy(s,str); }
void operator==(comp);
};
void comp::operator==(comp ob)
{ if(strcmp(s,ob.s)==0)
cout<<"\nStrings are Equal";
else
cout<<"\nStrings are not Equal"; }
int main()
{ comp ob, ob1;
char string1, string2;
cout<<"Enter First String:";
cin>>string1;
ob.getstring(string1);
cout<<"\nEnter Second String:";
cin>>string2;
ob1.getstring(string2);
ob==ob1;
return 0; }

What types of operands are used for the overloaded operator?

Evaluation - Section - D | Q 4. (vi) | Page 259

Answer the question based on the following program.

#include<iostream>
#include<string.h>
using namespace std;
class comp {
public:
char s;
void getstring(char str)
{ strcpy(s,str); }
void operator==(comp);
};
void comp::operator==(comp ob)
{ if(strcmp(s,ob.s)==0)
cout<<"\nStrings are Equal";
else
cout<<"\nStrings are not Equal"; }
int main()
{ comp ob, ob1;
char string1, string2;
cout<<"Enter First String:";
cin>>string1;
ob.getstring(string1);
cout<<"\nEnter Second String:";
cin>>string2;
ob1.getstring(string2);
ob==ob1;
return 0; }

Which constructor will get executed in the above program? Write the output of the program?

CASE STUDY [Page 259]

### Tamil Nadu Board Samacheer Kalvi solutions for Class 11th Computer Science Answers Guide Chapter 15 Polymorphism CASE STUDY [Page 259]

CASE STUDY | Q 1. | Page 259

Suppose you have a Kitty Bank with an initial amount of Rs500 and you have to add some more amount to it. Create a class 'Deposit' with a data member named 'amount' with an initial value of Rs500. Now make three constructors of this class as follows:

1. without any parameter - no amount will be added to the Kitty Bank

2. has a parameter which is the amount that will be added to the Kitty Bank

3. whenever an amount is added an additional equal amount will be deposited automatically.

Create an object of the 'Deposit’ and display the final amount in the Kitty Bank.

## Solutions for Chapter 15: Polymorphism

Evaluation - Section - AEvaluation - Section - BEvaluation - Section - CEvaluation - Section - DCASE STUDY ## Tamil Nadu Board Samacheer Kalvi solutions for Class 11th Computer Science Answers Guide chapter 15 - Polymorphism

Shaalaa.com has the Tamil Nadu Board of Secondary Education Mathematics Class 11th Computer Science Answers Guide Tamil Nadu Board of Secondary Education solutions in a manner that help students grasp basic concepts better and faster. The detailed, step-by-step solutions will help you understand the concepts better and clarify any confusion. Tamil Nadu Board Samacheer Kalvi solutions for Mathematics Class 11th Computer Science Answers Guide Tamil Nadu Board of Secondary Education 15 (Polymorphism) include all questions with answers and detailed explanations. This will clear students' doubts about questions and improve their application skills while preparing for board exams.

Further, we at Shaalaa.com provide such solutions so students can prepare for written exams. Tamil Nadu Board Samacheer Kalvi textbook solutions can be a core help for self-study and provide excellent self-help guidance for students.