TN Board 11th Computer Science Important Questions Chapter 15 Polymorphism

TN State Board 11th Computer Science Important Questions Chapter 15 Polymorphism

Question 1.
Define polymorphism.
Answer:
The word polymorphism means many forms (poly – many, morph – shapes). Polymorphism is the ability of a
message or function to be displayed in more than one form.

Question 2.
In C++ how the polymorphism is achieved.
Answer:
In C++, polymorphism is achieved through function overloading and operator overloading.

Question 3.
What does the overloaded function refers to?
Answer:
An ‘overloaded function’ refers to a function having more than one distinct meaning.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 4.
Define overload resolution.
Answer:
The process of selecting the most appropriate overloaded function or operator is called overload resolution.

Question 5.
What is function’s signature?
Answer:
The number and types of a function’s parameters are called the function’s signature.

Question 6.
Write the output for the following code.
#include<iostream>
using namespace std;
class Data
{
public:
void print(int i)
{
cout<<“printing int: “<<i<<endl ;
}
void print(double f)
{
cout<<“printing float: “<<f<<endl;
}
void print(char ch)
{
cout<<“printing character: “<<ch<<endl ;
}
};
int main(void)
{
Data d;
d.print(7); //call print to print integer
d.print (50.3) //call print to print float
d.print(“function overloading”)
//call print to print character
return 0;
}
Answer:
Output:
printing int : 7
printing float : 50.3
printing character : function overloading.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 7.
Rewrite the following program after removing the syntactical error(s) if any. Underline each correction.
#include[iostream]
Class Employee
{
int Empld=101;
char Ename[20];
public
Employee{ } { }
void Join( )
{
cin>>EmplD;
gets(EName);
}
void list( )
{
cout<<Empld<< “:”<<Ename<<endl;
}
};
int main( )
{
Employee E;
Join.E( );
E.List( )
}
Answer:
#include<iostream>
using namespace std;
class Employee
{
int Empld;
char Ename[20];
public:
Employee( )
{
EmpId=101;
}
void Join( )
{
cin>>EmpId;
gets(Ename);
}
void list( )
{
cout<<EmpId<<“: “<<Ename<<endl;
}
};
int main( )
{
Employee E;
Join.E ( ) ;
E. List ( ) ;
}

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 8.
Write the definition of a function Fixpay( ) (float Pay[ ],int N), which should modify each element of the array salary pay N elements, as per the following rules.

TN State Board 11th Computer Science Important Questions Chapter 15 Polymorphism 1

Answer:
void Fixpay (float pay[ ], int N)
{
for(int i=0; i<N; i:++)
{
if(pay[i]<50000)
pay[i] += pay[i] * 0.35;
else if(pay[i]>50000 && pay[i] < 100000)
pay[i] += pay[i] * 0.30;
else
pay[i] += pay[i] * 0.20; .
}
}

Question 9.
Find the syntax errors in the following program segment. Give your reason as well,
class MNQ
{
int x = 30;
float y;
MNQ( )
(y = 33;}
~ ( ) { }
int main( )
{
MNQ M1, M2
}
Answer:
The following are the errors in the given program segment:

TN State Board 11th Computer Science Important Questions Chapter 15 Polymorphism 2

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 10.
Answer the questions (i) and (ii) after going through the following program,
class Match
{
int Time;
public:
Match( ) //Function 1
{
Time = 0;
cout<< “Match commences”<<endl;
}
void Details( ) //Function 2
{
cout<< “Inter Section Basketball Match”<<endl;
}
Match(int Duration) //Function 3
{
Time = Duration;
cout<< “Another Match begins now”«endl;
}
Match(Match & M) //Function 4
{
Time = M.Duration;
cout<< “Like Previous Match”<<endl;
}
};
(i) Which category of Constructor-Function 4 belongs to and what is the purpose of using it?
(ii) Write statements that would call the member functions 1 and 3.
Answer:
(i) Copy constructor, it is invoked when an object is created and initialized with values of an already existing object.
(ii) Match M1; //for function 1
Match M2(90); //for function 3

Question 11.
Answer the questions (i) and (ii) after going through the following program.
class Train
{
int Train No, Track;
public:
Train( ); //Function 1
Train (int TN); //Function 2
Train (Train & T); //Function 3
void Allocate( ); //Function 4
void move( ); //Functions 5
void main( )
{
Train T;
}
(i) Out of the following, which of the option is correct for calling function 2?
Answer:
Option 1-Train N(M);
Option 2-Train P(10);

(ii) Name the feature of object oriented programming, which is illustrated by function 1, function 2 and function 3 combined together.
Answer:
(i) Option 2 is correct for calling function 2.
(ii) Function overloading, i.e., Polymorphism.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 12.
Write a C++ program to find the perimeter of a rectangle using constructor overloading in a class. To find the perimeter of a rectangle using constructor overloading in a class.
Answer:
// constructor declared as outline member function
#include<iostream>
using namespace std;
class Perimeter
int 1, b, p;
public:
Perimeter ( );
Perimeter (int);
Perimeter (int,int);
Perimeter (Perimeters);
void Calculate( );
};
Perimeter::Perimeter( )
{
cout<<“\n Enter the value of length and breadth”; cin>>1>>b;
cout<<“\n\nNonParameterized constructor”;
}
Perimeter::Perimeter(int a)
{
1=b=a;
cout<<“\n\n Parameterized constructor with one argument”;
}
Perimeter::Perimeter(int 11, int b1)
{
cout<<“\n\n Parameterized constructor with 2 argument”;
1=11;
b=b1;
}
Perimeter::Perimeter(Perimeter&p)
{
l = p.1;
b = p.b;
cout<<“\n\n copy constructor”;
}
void Perimeter::Calculate( )
{
p = 2*(l+b);
cout<<p;
}
int main( )
{
Perimeter Obj ;
cout<<“\n perimeter of rectangle is”;
Obj.Calculate( );
Perimeter Obj1(2);
cout<<“\n perimeter of rectangle”;
Obj1.Calculate( ) ;
Perimeter Obj2(2, 3);
cout<<“\n perimeter of rectangle”;
Obj 2.Calculate( );
Perimeter obj3 (0bj2);
cout,<<“\n perimeter of rectangle”;
obj 3.Calculate ( );
return 0;
}
Output:
Enter the value of length and breadth 10 20
Non Parameterized constructor perimeter of rectangle is 60
Parameterized constructor with one argument
perimeter of rectangle 8
Parameterized constructor with 2 argument
perimeter of rectangle 10 copy constructor
perimeter of rectangle 10

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 13.
What is function overloading? Write a C++ program to demonstrate function overloading?
Answer:
The ability of the function to process the message or data in more than one form is called as function overloading.
C++ program to demonstrate function overloading.
#include<iostream>
using namespace std;
void print(inti)
{cout<<“It is integer” <<i<<endl;
void print(double f)
{
cout<<“It is float”<<f<<endl;
}
void print(string c)
{
cout<<“It is string”<<e<<ertdl;
}
int main( )
{
print(10);
print(10.10);
print(“Ten”);
return 0;
}
Output:
It is integer 10
It is float 10.1
It is string Ten

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 14.
What do you mean by constructor overloading? Explain with example.
Answer:
Function overloading can be applied for constructors, as constructors are special functions of classes. A class can have more than one constructor with different signature.
Constructor overloading provides flexibility of creating multiple type of objects for a class.
Constructor overloading
#include<iostream>
using namespace std;
class add
{
int num1, num2, sum;
public:
add ( )
{
cout<<“\n Constructor without parameters…”;
num1 = 0;
num2= 0;
sum =0;
}
add(int s1, int s2)
{
cout<<“\n Parameterized constructor…
num1=s1;
num2-s2;
sum=0;
}
add(add &a)
{
cout<<“\h Copy Constructor…”;
num1=a.num1;
num2=a.num2;
sum=0;
} _
void getdata( )
{
cout<<“\nEnter data ….”;
cin>>num1 >>num2 ;
}
void addition( )
{
sum=num1 + num2;
}
void putdata( )
{
cout<<“\n The numbers are…”;
cout<<numl<< ‘\t’ <<num2; cout<<“\n The sum of the numbers are. . . “<< sum;
}
};
int main( )
{
add a,b(10,20), c(b);
a. getdata ( );
a.addition ( );
b. addition ( );
c. addition( );
cout<<“\n Object a :”;
a. putdata ( );
cout<<“\n Object b :”;
b. putdata( );
cout<<“\n Object c…”;
c. putdata( );
return 0;
}
Output:
Constructor without parameters….
Parameterized constructor…
Copy Constructor …
Enter data … 20 30
Object a :
The numbers are.. 20 30
The sum of the numbers are… 50
Object b :
The numbers are..10 20
The sum of the numbers are… 30
Object c..
The numbers are..10 20
The sum of the numbers are… 30

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 15.
Suppose you have a Kitty Bank with an initial amount of ? 500 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 ? 500. Now make three constructors of this class as follows:
(i) Without any parameter – no amount will be added to the Kitty Bank.
(ii) Having a parameter which is the amount that will be added to the Kitty Bank.
(iii) whenever amount is added an additional equaly amount will be deposited automatically.
Create an object of the ‘Deposit’ and display the final amount in the Kitty Bank.
Answer:
#include<iostream>
using namespace std;
class Deposit
{
int amount;
public:
AddAmount( )
{
amount = 500;
}
AddAmount(int a)
{
amount = 500;
amount = a+amount;
}
void Print_amount( )
{
cout<<amount<<endl;
}
} ;
int main( )
{
Deposit a1;
Deposit a2(150);
a1.Print_amount( );
a2.Print_amount ();
return 0;

Question 16.
What is function overloading?
Answer:
The ability of the function to process the message or data in more than one form is called as function overloading.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 17.
List the operators that cannot be overloaded.
Answer:
The operator that cannot be overload are:
(i) scope operator::
(ii) sizeof
(iii) member selector.
(iv) member pointer selector *
(v) ternary operator ?:

Question 18.
class add{int x; public: add(int)}; Write an outline definition for the constructor.
Answer:
add::add(int y)
{
x=y;
}

Question 19.
Does the return type of a function help in overloading a function?
Answer:
No, the return type of a function does not help in overloading a function.

Question 20.
What is the use of overloading a function?
Answer:
Function overloading is not only implementing polymorphism but also reduces the number of comparisons in a program and makes the program to execute faster. It also helps the programmer by reducing the number of function names to be remembered.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 21.
What are the rules for function overloading?
Answer:
Rules for function overloading:

  1. The overloaded function must differ in the number of its arguments or data types.
  2. The return type of overloaded functions are not considered for overloading same data type.
  3. The default arguments of overloaded functions are not considered as part of the parameter list in function overloading.

Question 22.
How does a compiler decide as to which function should be invoked when there are many functions? Give an example.
Answer:
When an overloaded function is called, the compiler determines the mo§t appropriate
definition to use, by comparing the argument types that has been used to call the function with the parameter types specified in the definitions.
Eg:
float area (float radius);
float area (float half, float base, float height) ;
float area (float length , float breadth);

Question 23.
What is operator overloading? Give some example of operators which can be overloaded.
Answer:
The term operator overloading, refers to giving additional functionality to the normal C++ operators like +, + +, -, —, + =, – =, *.<, >. It is also a type of polymorphism in which an operator is overloaded to give user defined meaning to it.
Eg: ‘+’ operator can be overloaded to perform addition on various data types, like for Integer, String(concatenation) etc.

Question 24.
Discuss the benefit of constructor overloading?
Answer:
Function overloading can be applied for constructors, as constructors are special functions of classes. A class can have more than one constructor with different signature. Constructor overloading provides flexibility of creating multiple type of objects for a class.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 25.
class sale (int cost, discount jpublic: sale(sale &); Write a non-inline definition for constructor specified;
Answer:
sale::sale(sale&s)
{
cost-s.cost;
discount=s.discount;
}

Question 26.
What are the rules for operator overloading?
Answer:
(i) Precedence and Associativity of an Operator cannot be changed.
(ii) No new operators can be created, only existing operators can be overloaded.
(iii) Cannot redefine the meaning of an operator’s procedure.
(iv) Overloaded operators cannot’ have default arguments.
(v) When binary operators are overloaded, the left hand object must be an object of the relevant class.

Question 27.
Answer the question (i) to (v) after going through the following class.
classBook
{
intBookCode;
char Bookname[20];
float fees;
public:
Book( ) //Function X
{
fees=1000;
BookCode=l;
strcpy (Bookname “C++”);
}
void display(float C) //Function 2
{
cout«Book code <<“:”<< Bookname << “:” << fees << endl;
}
~Book( ) //Function 3
{
cout<<“End of Book Object”<<endl;
}
Book (intS[ ], char S[ ], float F); //Function 4 };
(i) In the above program, what are Function 1 and Function 4 combined together referred as?
(ii) Which concept is illustrated by Function3? When is this function called/ invoked?
(iii) What is the use of Function 3?
(iv) Write the statements in main to invoke functionl and function 2.
(v) Write the definition for Function 4.
The concept demonstrated is constructor overloading.
(i) Function 1 and Function 4 are called overloaded constructor of the class Book.
(ii) Function 3 is destructor of class Travel. The destructors are called automatically when the objects are destroyed.
(iii) Function 3 is used to deallocate memory.
(iv)
Book B;
B.display(1000);
(v)
Book(int sc, char s[ ], float F)
{
Bookcode = sc; strcpy(Bookname, s);
Fees = F;
}

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 28.
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;
}
};
intmain( )
{
Seminar s1, s2(2), s3(s2);
s1.Lecture( );
return 0;
}
Answer:
Output:
Seminar starts now
Welcome to Seminar
Welcome to Seminar
Lectures in the Seminar on
Vote of thanks
Vote of thanks
Vote of thanks

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 29.
Debug the following program.
#include<iostream>
using namespace std;
class String
{
public:
charstr[20];
public:
void accept_string
{
cout<<“\n Enter String:”; cin»str;
}
display_string( )
{
cout<<str;
}
String operator *(String x) //Concatenating String
{
String s;
strcat(str,str);
strcpy(s.str,str);
goto s;
}
}
int main( )
{
String str1, str2, str3;
str1.accept_string( );
str2.accept_string( );
cout<<“\n\n First String is:”;
str1=display_string( );
cout<<“\n\n Second String is:”;
str2.display_string( );
str3=str1 + str2;
cout>>”\n\n Concatenated String is:”;
str3.display_string( );
return 0;
}
Answer:
#include<iostream>
using namespace std;
class String
{
public: char str[20];
public:
void accept_string( )
cout<<“\n Enter String:”;
cin>>str;
}
void display_string( )
{
cout<<str;
}
String operator +(String x) //Concatenating String
{
string s
strcat(str,x.str) ; strcpy(s.str, str) ; return s;
};
int main ( )
{
String str1, str2, str3;
strl.accept_string( );
str2.accept_string( );
cout<<“\n\n First String is:”;
str1.display_string( );
cout<<“\n\n Second String is:”;
str2.display_string();
str3=str1+str2;
cout>>”\n\n Concatenated String is : “;
str3.display_string( );
return 0;
}
Output:
Enter String : COMPUTER
Enter String : SCIENCE
First String is : COMPUTER
Second String is : SCIENCE
Concatenated String is : COMPUTER SCIENCE

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 30.
Answer the questions based on the following program.
#include<iostream>
#include<$tring.h>
using namespace std;
class comp
{
public:
chars[10];
void getstring(char str[10])
{
strcpy(s,str);
}
void operator==(comp);
};
void comp::operator==f(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[10], string2[10];
cout<<“Enter First String:”;
cin>>string1;
ob.getstring(string1);
cout<<“\nEnter Second String:”;
cin>>string2;
ob1.getstring(string2);
ob==ob1;
return 0;
}
(i) Mention the objects which will have the scope till the end of the program.
(ii) Name the object which gets destroyed in between the program.
(iii) Name the operator which is overloaded and write the statement that invokes it.
(iv) Write out the prototype of the overloaded member function.
(v) What types of operands are used for the overloaded operator?
(vi) Which constructor will get executed? Write the output of the program.
Answer:
(i) ob, ob1
(ii) ob1
(iii) The operator that is overloaded is == The statement that invokes it ob==ob1
(iv) void operator ==(comp ob);
(v) string
(vi) default constructor is executed
Output:
Enter First String : Computer
Enter Second String : Computer
Strings are Equal

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Choose the correct answer:

Read the following C++ program carefully and answer questions from 1-3.
#include<iostream.h>
class negative
{
int i;
public:
void accept( )
{
cin>>i;
}
void display( )
{
cout<<i;
}
void operator-( )
{
i=-i;
}
};
void main( )
{
negative n2;
n2.accept ( );
-n2;
n2.display( ) ;
}

Question 1.
Identify the operator that is overloaded:
(a) =
(b) – (Unary)
(c) – (Binary)
(d) negative
Answer:
(c) – (Binary)

Question 2.
The prototype of the overloaded member function is:
(a) negative operator – ( )
(b) void operator minus
(c) void operator – ( )
(d) void operator – (negative)
Answer:
(c) void operator – ( )

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 3.
Which of the following statements invokes the overloaded member function?
(a) Negative n1 ( )
(b) – – n2 ( )
(c) n2 +;
(d) – n2;
Answer:
(d) – n2;

Question 4.
The mechanism of giving special meaning to an operator is called:
(a) Operator Overloading
(b) Function Overloading
(c) Inheritance
(d) Object
Answer:
(a) Operator Overloading

Question 5.
Which of the following is not a valid function prototype?
(a) void fun (int x) ;
void fun (int y);
(b) void fun (int x, int y);
void fun (int x, float y) ;
(c) int fun(: int x);
void fun (float x) ;
(d) void fun (char x) ;
void fun(char x, int y) ;
Answer:
(a) void fun (int x) ;
void fun (int y);

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 6.
Polymorphism is achieved in C++ through:
(a) Encapsulation
(b) Inheritance
(c) Overloading
(d) Function
Answer:
(c) Overloading

Question 7.
Which of the following operators cannot be overloaded?
(a) +
(b) ++
(c) +=
(d) ::
Answer:
(d) ::

Question 8.
While overloading functions, the possible integral promotions are:
(a) char → int
(b) int → char
(c) both (a) and (b)
(d) none of these
Answer:
(c) both (a) and (b)

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 9.
In operator overloading the operator functions must be defined as:
(a) member function
(b) friend function
(c) either (a) or (b)
(d) neither (a) nor (b)
Answer:
(c) either (a) or (b)

Question 10.
The functionality of ‘+’ operator can be extended to strings through:
(a) operator precedence
(b) operator overloading
(c) operator definition
(d) none of the given
Answer:
(b) operator overloading

Question 11.
The overloaded operator must have at least one operand of:
(a) built-in type
(b) user-defined type
(c) array
(d) derived
Answer:
(b) user-defined type

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 12.
Which one of the following cannot be overloaded?
(a) Constructor
(b) Destructor
(c) Operator
(d) Function
Answer:
(b) Destructor

Question 13.
The __________ arguments of overloaded functions are not considered by the C++ compiler as part of the parameter list.
(a) actual
(b) reference
(c) formal
(d) default
Answer:
(d) default

Question 14.
During overloading of which of the following operators,the left hand object must be an object of the relevant class?
(a) Unary
(b) Binary
(c) Ternary
(d) None of these
Answer:
(b) Binary

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 15.
Which of the following terms means a name having two or more distinct meanings?
(a) Data Abstraction
(b) Encapsulation
(c) Inheritance
(d) Overloading
Answer:
(d) Overloading

Question 16.
The overloaded function definitions are permitted for which of the following data types?
(a) Built in
(b) User defined
(c) Derived
(d) All of these
Answer:
(b) User defined

Question 17.
Which of the following is not true related to function overloading?
(a) Each overloaded function must differ by the number of its formal parameter
(b) The return type of overloaded functions may be the same data type
(c) The default arguments are considered by the C++ compiler as part of the parameter list
(d) Do not use the same function name for two unrelated functions
Answer:
(c) The default arguments are considered by the C++ compiler as part of the parameter list

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 18.
By integral promotions, int data type can be converted into which of the following?
(a) char
(b) double
(c) float
(d) all of these
Answer:
(d) all of these

Question 19.
Integral promotions are purely:
(a) compiler oriented
(b) computer oriented
(c) data oriented
(d) program oriented
Answer:
(a) compiler oriented

Question 20.
In polymorphism, the compiler adopts which strategy to match-function call statement?
(a) Best match
(b) Worst match
(c) Good match
(d) Next match
Answer:
(a) Best match

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 21.
In overloaded function, which are not considered by the C++ compiler as part of the parameter list:
(a) Dummy arguments
(b) Actual parameters
(c) Formal parameters
(d) Default arguments
Answer:
(d) Default arguments

Question 22.
Which operator cannot be overloaded?
(a) ::. size of ? :
(b) : size of + *
(c) + – * 7 :
(d) + . ? size of
Answer:
(a) ::. size of ? :

Question 23.
Which of the following C++ operators can be overloaded ?
(a) ::
(b) .
(c) ?:
(d) +
Answer:
(d) +

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 24.
The function operator( ) is declared in which part of the class ?
(a) public
(b) private
(c) protected
(d) static
Answer:
(a) public

Question 25.
Which of the following statements is false in case of operator overloading?
(a) Only existing operators can be overloaded
(b) The basic definition of an operator can be replaced
(c) The overloaded operator must have at least one operand of user defined type
(d) Binary operators overloaded through member function take one explicit argument.
Answer:
(b) The basic definition of an operator can be replaced

Question 26.
Operator <symbol>( ) must be declared under which access of the class?
(a) private
(b) prptect
(c) public
(d) protected
Answer:
(c) public

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 27.
Which of the following operators can be overloaded?
(a) size of ( )
(b) ::
(c) ++
(d) (.) membership operator
Answer:
(c) ++

Question 28.
In how many ways is polymorphism achieved in C++?
(a) 2
(b) 3
(c) 1
(d) 4
Answer:
(a) 2

Question 29.
How many explicit argument(s) is/are taken by binary operators overloaded through a member function?
(a) One
(b) Two
(c) Three
(d) Six
Answer:
(a) One

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 30.
Polymorphism is achieved through:
(a) function overloading
(b) operator overloading
(c) both (a) and (b)
(d) encapsulation
Answer:
(c) both (a) and (b)

Question 31.
The parameter list in function overloading must differ by:
(a) number of arguments
(b) function name
(c) function size
(d) number of functions
Answer:
(a) number of arguments

Question 32.
The operator that can be overloaded is:
(a) ::
(b) .
(c) sizeof( )
(d) + =
Answer:
(d) + =

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 33.
In C++, each overloaded function must differ either by the number of:
(a) function name
(b) actual parameter
(c) default parameter
(d) formal parameter
Answer:
(d) formal parameter

Question 34.
The ability of the function to process the message or data in more than one form is called as:
(a) function overloading
(b) operator overloading
(c) destructor overloading
(d) data overloading
Answer:
(a) function overloading

Question 35.
Which one of the following operator overload through a member function take one explicit argument?
(a) Unary
(b) Ternary
(c) Binary
(d) Conditional
Answer:
(c) Binary

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 36.
The overloaded operator must have at least how many operand of user defined data type?
(a) Two
(b) One
(c) Three
(d) Four
Answer:
(b) One

Question 37.
The overloaded operator must have atleast one operahd of:
(a) user definded
(b) class
(c) static
(d) Built in data
Answer:
(a) user definded

Question 38.
Which access specifier is used to declare operator () function in operator overloading?
(a) Private
(b) Protected
(c) Public
(d) Unprotected
Answer:
(c) Public

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 39.
The ability of an object to respond differently to different messages is called as:
(a) Encapsulation
(b) Polymorphism
(c) Inheritance
(d) Object
Answer:
(b) Polymorphism

Question 40.
The word ‘poly’ means:
(a) Class
(b) Shape
(c) Many
(d) Constructor
Answer:
(c) Many

Question 41.
In C++ which is achieved through overloading?
(a) Data hiding
(b) Encapsulation
(c) Inheritance
(d) Polymorphism
Answer:
(d) Polymorphism

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 42.
In C++, when binary operators are overloaded through a member function they take how many explicit arguments?
(a) Four
(b) Two
(c) One
(d) Three
Answer:
(c) One

Question 43.
Hierarchical database were primarily used in which computers?
(a) Super
(b) Mainframe
(c) Personal
(d) Micro
Answer:
(b) Mainframe

Question 44.
In C++, double data type can be converted into which data type during integral promotion?
(a) char
(b) int
(c) string
(d) void
Answer:
(b) int

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 45.
In C++, which of the following is achieved through function overloading and operator overloading?
(a) encapsulation
(b) data abstraction
(c) polymorphism
(d) inheritance
Answer:
(c) polymorphism

Question 46.
Identify the odd man out:
(a) Scope operation (::)
(b) Sizeof
(c) Member selector (.)
(d) Plus (+)
Answer:
(d) Plus (+)

Question 47.
Identify the incorrect statement in operator overloading:
(a) Precedence and Associativity can be changed.
(b) No new operators can be created only existing operators can be overloaded.
(c) Cannot redefine the meaning of an operator’s precedence.
(d) Overloaded operators cannot have default arguments.
Answer:
(a) Precedence and Associativity can be changed.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 48.
Identify the incorrect statement:
(a) Overloaded function refers to function having only one meaning.
(b) A class can have more than one constructor with different signature.
(c) ?: operator can be overloaded.
(d) Function overloaded makes the program to execute slower.
Answer:
(b) A class can have more than one constructor with different signature.

Question 49.
Which of the following refers to a function having more than one distinct meaning?
(a) Function overloading
(b) Member overloading
(c) Operator overloading
(d) Operations overloading
Answer:
(a) Function overloading

Question 50.
Which of the following reduces the number of Comparisons in a program?
(a) Operator overloading
(b) Operations overloading
(c) Function overloading
(d) Member overloading
Answer:
(c) Function overloading

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 51.
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
(a) dispchar( );
(b) dispchar(ch,size);
(c) dispchar($,10);
(d) dispchar(‘$’, 10 times);
Answer:
(a) dispchar( );

Question 52.
Which of the following is not true with respect to function overloading?
(a) The overloaded functions must differ in their signature.
(b) The return type is also considered for overloading a function.
(c) The default arguments of overloaded functions are not considered for Overloading.
(d) Destructor function cannot be overloaded.
Answer:
(b) The return type is also considered for overloading a function.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 53.
Which of the following is invalid prototype for function overloading?
(a) void fun (int x); void fun (char ch);
(b) void fun (int x); void fun (int y);
(c) void fun (double d); void fun (char ch);
(d) void fun (double d); void fun (int y);
Answer:
(b) void fun (int x); void fun (int y);

Question 54.
Which of the following function(s) combination cannot be considered as overloaded function(s) in the given snippet?
void print(char A,int B); // F1
void printprint (int A, float B) ; // F2
void Print(int P=10); // F3
void print( ); // F4
(a) F1,F2,F3,F4
(b) F1,F2,F3
(c) F1,F2,F4
(d) F1,F3,F4
Answer:
(a) F1,F2,F3,F4

Question 55.
Which of the following operator is by default
overloaded by the compiler?
(a) *
(b) +
(c)+=
(d) = =
Answer:
(d) = =

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Based on the following program answer the questions (8) to (10)
#include<iostream>
using namespace std;
class Point
{
private:
int x, y;
public: .
Point (int x1,int y1)
{ ,
x=x1;y=y1;
}
void operatort+(Point &pt3);
void show( )
{
cout<<“x=”<<x<<“, y=”<<y;
}
};
void Point::operator+(Point &pt3)
{
x += pt3.x;
y += pt3.y;
}
int main( )
Point pt1 (3, 2), pt2(5, 4);
pt1 + pt2;
pt1.show ( );
return 0;
}

Question 56.
Which of the following operator is overloaded?
(a) +
(b) operator
(c) ::
(d) =
Answer:
(a) +

Question 57.
Which of the following statement invoke operator overloading?
(a) pt1 + pt2;
(b) point pt1 (3,2), pt2(5,4);
(c) ptl.show( );
(d) return 0;
Answer:
(a) pt1 + pt2;

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 15 Polymorphism

Question 58.
What is the output for the above program?
(a) x = 8, y = 6
(b) x = 14, y = 14
(c) x = 8, y = 6
(d) x = 5, y = 9
Answer:
(a) x = 8, y = 6

TN Board 11th Computer Science Important Questions