TN State Board 11th Computer Science Important Questions Chapter 14 Classes and Objects

Question 1.
What is a class?
Answer:
In C++ a class is defined using the keyword class followed by the name of the class. The body of the class is defined inside the curly brackets and terminated either by a semicolon or a list of declarations at the end.

Question 2.
What are the features present in OOP languages?
Answer:
Abstraction, Encapsulation, Inheritance and Polymorphism.

Question 3.
What is data hiding?
Answer:
Data hiding is one of the important features of Object Oriented Programming which allows preventing the functions of a program to access directly the internal representation of a class type.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 4.
What are access specifiers?
Answer:
The keywords public, private and protected are called access specifiers.

Question 5.
What are the ways to define the member functions of a class?
Answer:
The member functions of a class can be defined in two ways. They are:

  1. Inside the class definition
  2. Outside the class definition

Question 6.
What do you mean by Array of objects?
Answer:
An array which contains the class type of element is called array of objects. It is declared and defined in the same way as any other type of array.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 7.
What is scope resolution operator?
Answer:
If there are multiple variables with the same name defined in separate blocks then :: (scope resolution) operator will reveal the hidden file scope(global) variable.

Question 8.
How the objects are passed to a function?
Answer:
Objects can be passed as arguments to a member function just like any other data type of C++.
Objects can also be passed in both ways:

  1. Pass By Value
  2. Pass By Reference

Question 9.
What do you mean by Nested class?
Answer:
When one class become the member of another class then it is called Nested class and the relationship is called containership.
Classes can be nested in two ways.

  1. By defining a class within another class.
  2. By declaring an object of a class as a member to another class.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 10.
Why constructors are advised to define in the public section? Give reason.
Answer:
A constructor can be defined either in private or public section of a class. But it is advisableto defined in public section of a class, so that 16. What do you mean by Inline member its object can be created in any function. functions.

Question 11.
What are the functions of Constructor?
Answer:

  1. To allocate memory space to the object and
  2. To initialize the data member of the class object.

Question 12.
What do you mean by default constructor?
Answer:
A constructor that accepts no parameter is called default constructor. For example in the class data program Data ::Data( ) is the default constructor. Using this constructor, objects are created similar to the way the variables of other data types are created.
int num; //ordinary variable declaration
Data dl; //object declaration
If a class does not contain an explicit constructor (user defined constructor) the compiler automatically generate a default constructor implicitly as an inline public member.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 13.
What are the ways to create an object using parameterized constructor?
Answer:
There are two ways to create an object using parameterized constructor. They are:

  1. Implicit call
  2. Explicit call

Question 14.
What is explicit call?
Answer:
An explicit call to constructor creates temporary instance which remains in the memory as long as it is used and after that it get released.

Question 15.
What is Destructor?
Answer:
When a class object goes out of scope, a special function called the destructor gets executed. The destructor has the same name as the class tag but prefixed with a ~(tilde). Destructor function returns nothing and it is not associated with anydata type.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 16.
What do you mean by Inline member functions?
Answer:
When a member function is defined inside a class, it behaves like inline functions. These are called Inline member functions.

Question 17.
What is container class?
Answer:
Whenever an object of a class is declared as a member of another class it is known as a container class. In the container-ship, the object of one class is declared in another class.

Question 18.
Write the general form of a class definition.
Answer:
The General Form of a class definition
class class-name
{
private:
variable declaration;
function declaration;
protected:
variable declaration;
function declaration;
public:
variable declaration;
function declaration;
};
(i) The class body contains the declaration of its members (Data member and Member functions).
(ii) The class body has three access specifiers, private, public and protected.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 19.
Why do you need a class?
Answer:
Class is a way to bind the data and its associated functions together. Classes are needed to represent real world entities that not only have data type properties but also have associated operations. It is used to create user defined data type.

Question 20.
Explain the access specifiers with example.
Answer:
The access specifiers are public, private and protected.

The Public Members:
A public member is accessible from anywhere outside the class but within a program. User can set and get the value of public data members even without using any member function. ,

The Private Members:
A private member cannot be accessed from outside the class. Only the class member functions can access private members. By default all the members of a class would be private.

The Protected Members:
A protected member is very similar to a private member but it provides one additional benefit that they can be accessed in child classes which are called derived classes (inherited classes).

TN State Board 11th Computer Science Important Questions Chapter 14 Classes and Objects 1

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 21.
Write short note on outside the class definition.
Answer:
When a member function defined outside the class is just like normal function definition then it is be called as outline member function or non-inline member function. Scope resolution operator (::) is used for this purpose. The syntax for defining the outline member function is
Syntax:
return_type class_name :: function_name (parameter list) .
{
function definition
}

TN State Board 11th Computer Science Important Questions Chapter 14 Classes and Objects 2

Question 22.
What are the methods to create objects?
Answer:
A class specification defines the properties of a class. To make use of a class specified, the variables of that class type have to be declared. The class variables are called object. Objects are also called as instance of class.
Eg: student s;
In the above statement s is an instance of the class student. Objects can be created in two methods,
(i) Global object
(ii) Local object.

(i) Global Object:
If an object is declared outside all the function bodies or by placing their names immediately after the closing brace of the class declaration then it is called as Global object. These objects can be used by any function in the program.

(ii) Local Object:
If an object is declared within a function then it is called local object. It cannot be accessed from outside the function.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 23.
How will you declare and define the constructor?
Answer:
When an instance of a class comes into scope, a special function called the constructor gets executed. The constructor function name has the same name as the class name. The constructors return nothing. They are not associated with any data type. It can be defined either inside class definition or outside the class definition.
Eg: A constructor defined inside the class specification.
#include<iostream>
using namespace std;
class Sample
{
int i, j;
public :
int k;
Sample ( )
{
i=j=k=0;//constructor defined
inside the class
}
};

Question 24.
What is a copy constructor? When will the copy constructor is called?
Answer:
A constructor having a reference to an already existing object of its own class is called copy constructor.
A copy constructor is called
(i) When an object is passed as a parameter to any of the member functions.
Eg: void simple: :putdata(simple x);
(ii) When a member function returns an object.
Eg: simple getdata() {}
(iii) When an object is passed by reference to an instance of its own class.
Eg: simples 1, s2(s1); // s2(s1) calls copy constructor

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 25.
Why there is a need for constructors?
Answer:
Need for Constructors:
An array or a structure in C++ can be initialized during the time of their declaration.
Eg:
struct sum
{
int n1,n2;
};
class add
{
int num1,num2;
};
int main ( )
{
int arr[ ]={1,2,3}; //declaration and initialization of array
sum s1={l,l}; //declaration and initialization of structure object
add a1={0,0}; // class object declaration and initialization throws compilation error
}
The initialization of class type object at the time of declaration similar to a structure or an array is not possible because the class members have their associated access specifiers (private or protected or public). Therefore Classes include special member functions called as constructors. The constructor function initializes the class object.

Question 26.
Write short note on memory allocation of objects. Give example.
Answer:
(i) The member functions are created and placed in the memory space only when they are defined as a part of the class specification.
(ii) All the objects belonging to that class use the same member function, no separate space is allocated for member functions when the objects are created.
(iii) Memory space required for the member variables are only allocated separately for each object because the member variables will hold different data values for different objects.
Eg:
Memory allocation for objects:
#include<iostream>
using namespace std;
class product
{
int code,quantity;
float price;
public:
void assignData( );
void Print( );
};
int main( )
{
product p1, p2;
cout<<\n Memory allocation for object pi “<<sizeof (pi) ; cout<<\n Memory allocation for object p2 “<<sizeof(p2); return 0;
}
Output:
Memory allocation for object p1 12
Memory allocation fdr object p2 12

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 27.
How will you reference a class member?
Answer:
The members of a class are referenced (accessed) by using the object of the class followed by the dot (membership) operator and the name of the member.
The general syntax for calling the member function is:
Object_name. fimction_name(actual parameter);

TN State Board 11th Computer Science Important Questions Chapter 14 Classes and Objects 3

Question 28.
Explain pass by value with example.
Answer:
When an object is passed by value, the function creates its own copy of the object and works on it. Therefore any changes made to the object inside the function do not affect the original object.
C++ program to illustrate how the pass by value method work:
#include<iostream>
using namespace std;
class Sample
{
private: int num; public:
void set(int x)
{
num = x;
}
void pass(Sample obj1, Sample obj2) //objects are passed
{
obj1.num=100; // value of the object is changed inside the function
obj2.num=200; // value of the object is changed inside the function
cout<<“\n\n Changed value of object1″<<obj 1. num;
eout<<“\n\n Changed value of object2″<<obj2 .num;
}
void print( )
{
cout<<num;
}
};
int main( )
{
//object declarations
Sample s1;
Sample s2;
Sample s3;
//assigning values to the data member of objects
s1.set (10);
s2.set (20);
cout<<“\n\t\t Example program for pass by value\n\n\n”;
//printing the values before passing the object cout<<“\n\nValue of objectl before passing”;
s1.print ( );
cout<<“\n\nValue of object2 before passing”;
s2.print( );
//passing object si and s2 s3.pass (s1, s2);
//printing the values after returning to main cout<<“\n\nValue of objectl after passing”;
s1.print () ;
cout<<“\n\nValue of 0bject2 after passing”;
s2.print ( );
return 0;
}
Output;
Example program for PASS BY VALUE
Value of object1 before passing 10
Value of object2 before passing 20
Changed value of object 1 100
Changed value of object 2 200
Value of object 1 after passing 10
Value of object 2 after passing 20

In the above program the objects s1 and s2 are passed to pass( ) method. They are copied to obj 1 and obj2 respectively. The data member num’s value is changed inside the function. But it didn’t affect the s1 and s2 objects data member.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 29.
Explain pass by reference with example.
Answer:
When an object is passed by reference, its memory address is passed to the function. So the called function works directly on the original object used in the function call. So any changes made to the object inside the function definition are reflected in original object.

C++ program to illustrate how the pass by reference method work:
#include<iostream>
using namespace std;
class Sample
{
private:
int num;
public:
void set(int x)
{
num = x;
}
void pass(Sample &objl, Sample &obj2) //objects are passed
{
obj1.num=100; // value of the object is changed inside the function
obj2.num=200; // value of the object is changed inside the function
cout<<“\n\n Changed value of object1″<<obj1.num;
cout<<“\n\n Changed value of objeet2″<<obj2.num;
}
void pfint( )
{
cout<<num;
}
};
int main( )
{ … .
clrscr( );
//object declarations Sample si;
Sample s2;
Sample s3;
//assigning values to the data member of objects si.set(10);
s2.set(20) ;
cout<<“\n\t\t Example program for pass by reference\n\ n\n”;
//printing the values before passing the object
cout<<‘\\n\nValue of objectl before passing”;
s1.print ( ) ;
cout<<“\n\nValue of object2 before passing”;
s2.print( );
//passing object s1 and s2 s3.pass (s1, s2);
//printing the values after returning to main
Cout<<“\n\nValue of object1 after passing”;
s1.print( );
cout<<“\n\nValue of object2 after passing”;
s2.print ( );
return 0;
}
Output:
Example program for PASS BY REFERENCE
Value of object 1 before passing 10
Value of object 2 before passing 20
Changed value of object 1 100
Changed value of object 2 200
Value of object 1 after passing 100
Value of object 2 after passing 200

Question 30.
Explain the parameterized constructors with example.
Answer:
A constructor which can take arguments is called parameterized constructor. This type of constructor helps to create objects with different initial values. This is achieved by passing parameters to the function. To illustrate the Parameterized constructor used for creating objects:
#include<iostream>
using namespace std;
class simple
{
private:
int a,b;
public:
simple(int m,int n)
{
a= m ;
b= n;
cout<<“\n Parameterized Constructor of Class- simple”<<endl;
}
void putdata( )
{
cout<<“\nThe two integers are. . . “<<a<<‘\t'<< b<<endl; cout<<“\n The sum of the variables “<<a<<“+”<<b<<“=” <<a+b;
}
};
int main ( )
{
simple s1(10,20),s2 (30,45);
//Created two objects with different values created cout<<“\n\t\tObject 1\n”;
si.putdata( );
cout<<“\n\t\tObject 2\n”;
s2.putdata( );
return 0;
}
Output:
Parameterized Constructor of class-simple
Parameterized Constructor of class-simple
Object 1
The two integers are .. 10 20
The sum of the variables 10 + 20 = 30
Object 2
The two integers are… 30 45
The sum of the variables 30 + 45 = 75

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 31.
Write the characteristics of constructors.
Answer:

  1. The name of the constructor must be same as that of the class.
  2. No return type can be specified for constructor.
  3. A constructor can have parameter list.
  4. The constructor function can be overloaded.
  5. They cannot be inherited but a derived class can call the base class constructor.
  6. The compiler generates a constructor, in the absence of a user defined constructor.
  7. Compiler generated constructor is public member function.
  8. The constructor is executed automatically when the object is created.
  9. A constructor can be used explicitly to create new object of its class type.

Question 32.
Write the characteristics of destructors.
Answer:

  1. The destructor has the same name as that of the class prefixed by the tilde character ‘~’.
  2. The destructor cannot have arguments.
  3. It has no return type.
  4. Destructors cannot be overloaded i.e., there can be only one destructor in a class.
  5. In the absence of user defined destructor, it is generated by the compiler.
  6. The destructor is executed automatically when the control reaches the end of class scope to destroy the object.
  7. They cannot be inherited.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 33.
State the reason for the invalidity of the following code fragment.

(i)

(ii)

Class count

{

int first;

int second;

public;

int first;

};

Class item

{

int prd;

};

item int prdno;

Answer:
(i) Redeclaration of variable first.
(ii) Two or more datatypes in declaration of prdno.

Question 34.
class area
{
int s;
public:
void calc( );
};
Write an outline function definition for calc( ); which finds the area of a square.
Answer:
void area :: calc( )
{
cout<<“Enter the value of s”;
cin>>s;
cout<<“The area of square is”<<s*s
}

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 35.
Identify the error in the following code fragment
class A
{
float x;
void init( )
{
A a1;
X1.5=1;
void main( )
{A1.init( );}
Answer:
class A
{
float x;
public:
void init( )
{
x=1.5;
} };
int main( )
{
A a1;
a1.init( )
}

Question 36.
What is the size of the objects s1, s2?
Answer:
class sum
{
int n1,n2;
public:
void add( ){int n3=10;nl=n2=10;}
} s1,s2;
S1 8 bytes
S2 8 bytes

Question 37.
(i) Write member function called display with no return. The function should display all the member value of the class objects.
(ii) Try the output of the above coding with the necessary modifications.
Answer:
#include<iostream>
using namespace std;
class compute
{
int n1,n2;
public:
int n;
int add(int a,int b)
{
int c= a+b; return c;
}
int prd(int a,int b)
{
int c=a*b;
return c;
}
void display( )
{
compute c1,c2; .
c1 .n=c1..add(12, 15);
c2.n=c2..add(8, 4);
cout<<“\nSum of object-1” <<c1. n; .
cout<<“\nSum of objeet-2” <<c2.n;
cout<<“\n Sum of the two
objects are”<<c1. n+c2 . n;
c1.n=c1.prd(5, 4);
c2.n=c2.prd(2, 5);
cout<<“\nProduct of object-1” <<c1.n;
cout<<“\nProduct of object-2” <<c2 . n;
cout<<“\nProduct of two . objects are”<<c1.n*c2 .n;
}
};
int main( )
{
compute c;
c.display 0;
return 0;
}

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 38.
#include<iostream>
using namespace std;
class Sample
{
int i ,j;
public:
int k;
Sample( )
{
i=j=k=0;//constructor defined inside the
class
}
};
int main ( )
{
Samples1;
return 0;
}
Answer:
In the above program justify your reason for no output.
There is no cout statement in the above program.

Question 39.
Define a class in general and in C++’s context.
Answer:
The classes are the most important feature of C++ that leads to object oriented programming. Glass is a user defined data type, which holds its own data members and member functions, which can be accessed and used by creating instance of the class.

Question 40.
What is the purpose of a class specifier?
Answer:
The purpose of a class specifier is to identify the access rights for the data and member functions of the class.

Question 41.
Compare a structure and a class in C++ context.
Answer:

  1. Members of a class are private by default and members of struct are public by default.
  2. When deriving a struct from a class/struct, default access-specifier for a base class/struct is public. And when deriving a class, default access specifier is private.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 42.
Compare private and public access specifier.
Answer:
Private: The private member is not accessible from outside the class.
Public: The public members are accessible from outside the class, using objects of class.

Question 43.
What is non-inline member function? Write its syntax.
Answer:
When a member function is defined outside the class just like normal function definition then it is called as outline member function (or) non-inline member function.
Syntax:
return type class name :: function name
(parameter list)
{
Function definition
}

Question 44.
Define a class Employee with the following specification.
Answer:
private members of class employee:
empno – integer
ename – 20 characters
basic-float
netpay, hra, da, – float
calculate( ) – A function to find the basic+hra+da with float return type .
public member functions of class employee:
havedata( ) – A function to accept values for empno, ename, basic, hra, da and call calculate!) to compute netpay
dispdata( ) – A function to display all the data members on the screen
class employee
{
private:
int empno;
char ename[20];
float basic, hra, da, netpay;
float calculate ( ) ;
public:
vpid havedata( );
void dispdata( );
};
float employee :: calculated
{
return basic + hra + da;
}
void employee :: havedata( )
{
cout<<“\n Enter employee number”;
cin>>empno;
cout<<“\n Enter employee name”;
cin>> ename;
cout<<“\n Enter basic”;
cin>> basic; cout<<“\n Enter hra”;
cin>>hra;
cout<<“\n Enter da”;
cin>>da;
netpay = calculated ( );
}
void employee :: dispdata ( )
{
cout<<“\n Employee number”<<empno;
cout<<“\n Employee name”<<ename;
cout<<“\n Basic: “<<basic;
cout<<“\n HRA: “<<hra;
cout<<“\n DA:”<<da;
}

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 45.
Define a class MATH with the following specifications.
Answer:
private members:
num1, num2, result-float
init( ) function to initialize numl, num2 and result to zero
protected members:
add( ) function to add numl and num2 and store the sum in result
diff( ) function to subtract numl from num2 and store the difference in the result.

public members:
getdata( ) function to accept values for numl and num2
menu( ) function to.display menu
(i) Add…
(ii) Subtract…
invoke add( ) when choice is
(i) and invoke prod when choice is
(ii) and also display the result.
#include<iostream>
using namespace std;
class math
{
private:
float num1, num2, result;
int c;
void init( )
{
numl = 0.0;
num2 =0.0;
result =0.0;
}
protected: void add( )
{
result = num1 + num2;
cout<<“\n The sum is:”<<result;
void diff( )
{
result = numl-num2; cout<<“\n The product is:” <<result;
}
public:
void getdata( )
{
init ( )
cout<<“\n Enter numbers:”;
cin>>num1>>num2;
}
void menu( )
{
cout<<“\n1.Add”;
cout<<“\n2.Subtraction”;
cout<<“\n Enter your choice:”;
cin>>c;
if(c==1)
add( );
else
diff( );
}
};
int main( )
{
clrscr 0;
math m1; m1.getdata ( );
m1.menu( );
return 0;
}

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 46.
Create a class called Item with the following specifications.
private members:
code, quantity – Integer data type
price – Float data type
getdata( )-function to accept values for all data members with no return

public members:
tax – float
dispdata( ) member function to display code, quantity, price and tax. The tax is calculated as if the quantity is more than 100 tax is 2500 otherwise 1000.
Answer:
class item
{
private:
int code,quantity;
float price;
void getdata( )
{
cout<<“\n Enter code, quantity, price”;
cin>>code>>quantity>>price;
}
public:
float tax = 0.0;
void putdata( )
{
cout<<“\n code:”<<code;
cput<<“\n Quantity: “<<quantity;
cout<<“\n Price:”<<price;
if(quantity > 100) tax =2500;
else
tax = 1000;
cout<<“\n Tax:”<<tax;
}
};

Question 47.
Write the definition of a class FRAME in C++ with following description.
Private members:
FrameID – Integer data type
Height, Width, Amount – Float data type
SetAmount( ) -Member function to calculate and assign amount as 10*Height*Width
Public members
GetDetail( ) A function to allow user to entervalues of FramelD, Height, Width. This function should also call SetAmount( ) to calculate the amount.
ShowDetail( ) A function to display the values of all data members,
Answer:
class FRAME
{
int Frame ID;
float Height, Width , Amount;
void setAmount( )
{
Amount = 10*Height*Width;
}
Public:
void GetDetail( )
{
cout<<“Enter Frame ID”<<end-1;
cin>>Frame ID;
cout<<“Enter Height”<<endl;
cin>>Height;
cout<<“Enter Widthw<<endl;
cin>>Width; setAmount( );
}
void showDetail( )
{
cout«”Frame ID: “<<FrameID<<endl;
cout<<“Height: w<<Hpight<<endl;
cput<<”Width: “<<Width<<endl;
}
};

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 48.
Define a class RESORT in C++ with the following description:
Private Members :
Rno//Data member to store Room No
RName //Data member to store customer name
Charges //Data member to store per day charges
Days //Data member to store number of days of stay
COMPUTE( ) //A function to calculate and return Amount as
//Days*Charges and’ if the value of Days*Charges is more than 5000 then as 1.02*Days*Charges
Public Members:
Getinfo() //A function to enter the content Rno, Name, Charges and Days
Displayinfo( ) //A function to display Rno, RName, Charges, Days and
//Amount (Amount to displayed by calling functionCOMPUTE())
Answer:
class RESORT
{
int Rno, Days;
char RName[20];
float charges float COMPUTE ( )
public:
void Getinfo ( );
void Displayinfo( );
void RESORT :: Getinfo( )
{
cout<<“Room Number:'”;
cin>>Rno; cout<<,‘Name i gets(name);
cout<<”Charges:
cin>>Charges;
cput<<“Pays:w;
cin>>Days;
void RESORT :: Displayinfo( )
{
cout<<endl<<“Details as
follows:”<<endl<<“Ropm No: “<<RNo<<“\n Name : “;
puts(name);
cput<<“Charges: “<<Charges<<“\n Days: “<<Days<<“\n Amount: “<<Compute ( ) <<endl;
}
}
float RESORT : : COMPUTE ( )
{
float amount = Charges * Days;
if (amount > 5000)
amount = 1.02*Days*Charges;
return amount;
}

Question 49.
struct pno
{
int pin; float balance;
}
Create a BankAccount class with the following specifications
Protected members
pho_obj //array of 10 elements
init(pin) // to accept the pin number and initialize it and initialize
// the balance amount is 0
public members
deposit(pin, amount):
Increment the account balance by accepting the amount and pin. Check the pin number for matching. If it matches increment the balance and display the balance else display an appropriate message.

withdraw(self, pin, amount):

Decrement the account balance by accepting the amount and pin. Check the pin number for matching and balance is greater than 1000 and amount is less than the balance. If it matches withdraw the amount and display the balance else display an appropriate message.
Answer:
class BankAccount
{
protected:
char name[15];
int acc_no;
char acc_type;
float bal_amount;
public:
void readData( )
{
cout<<“\nEnter the name: “;
gets(name);
cout<<“\nEnter the account number: “;
cin>>acc_no;
cout<<“\nEnter the account type:
cin>>acc_t ype;
cout<<“\nEnter the amount to deposit:
cin>>bal_amount;
}
void deposit( )
{
float deposit;
cout<<“\nEnter your account number:
cin>>acc_no;
cout<<“\nEnter the amount to deposit: “;
cin>>deposit;
bal_amount=bal_amount + deposit;
}
void withdraw( )
{
float w_amount;
cout<<“\nEnter your account number: “;
cin>>acc_no;
cout<<“\nEnter amount to withdraw”;
cin>>w_amount;
if ((bal_amount-*w^amount) <1000)
cout<<“\nWithdraw is not possible”;
else
{
bal_amount=bali_amaunt-w_ amount;
cout<<“\nThe balance is”<<bal_ amount-w_amount;
}
}
void display( )
{
cout<<“\nName of the depositor :”<<name;
cout<<”\nAccount Number: “<<acc_ no;
cout<<“\nAcCount Type:”<<acc_ type;
cout<<“\nThe balance amount is”<<bal_amount;
}
};

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 50.
Define a class Hotel in C++ with the following description:
Private Members:
Rno //Data member to store Room No
Name //Data member to store customer name
Charges //Data member to store per day charges
Days //Data member to store number of days of stay
Calculate( ) //A function to calculate and return Amount as
//Days*Charges and if the value of Days*Charges is more than 12000 then as 1.2*Days*Charges

Public Members:
Hote{ } //to initialize the class members
Getinfo( ) //A function to enter the content Rno, Name, Charges//and Days
Showinfo( ) //A function to display Rno, RName, Charges, Days and
//Amount (Amount to displayed by calling function CALCULATE( ))
Answer:
class Hotel
{
int Rno, NOD;
char Name[30] float charges;
float calculate ( )
{
float temp = NOD*Charges;
if(temp>12000)
return (1.2*temp);
return temp;
}
public:
void Getinfo( )
{
cout<<“Enter the Room number:”<<endl;
cin>>Rno;
cout<<“Enter the customer .name:” <<endl;
gets(Name);
cout<<“Enter the Room charges per day”;<<endl;
cin>>charges;
cout<<“Enter number of days
stayed by customer”;<<endl;
cin>>NOD;
}
void Showinfo( )
{
cout<<“Room Number: “<<Rno<<endl ;
cout<<“Customer
Name:”<<puts (Name) ;
cout<<“Charges per . day: “<<charges<<endl;
cout<<“Number of days stayed by customer: “<<NOD;
cout<<“Total charges of customers: “<<calculate ( )
}
};

Question 51.
Define a class Exam in C++ with the following description:
Private Members:
Rollno – Integer data type
Cname – 25 characters
Mark – Integer data type

public:
Exam(int,char[ ],int) //to initialize the object
~Exam( ) // display message “Result will be intimated shortly”
void Display( ) // to display all the details if the mark is
// above 60 other wise display “Result Withheld”
Answer:
Class Exam
{
int Rolino;
char Cname[25];
int mark;
public:
Exam( )
{
Rollno=0;
strcpy(Cname,” “) ;
mark=0; .
}
~Exam( )
{
cout<<“Result will be intimated shortly”;
}
void Display( )
if(marks>60)
{
cout<<“Roll No:”<<Rollno;
cout<<“Name: “<<Cname;
cout<<“Marks: “<<marks;
}
else
{
cout<<“Result Withheld”;
}
};

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 52.
Define a class Student in C++ with the following specification:
Private Members:
A data member Rno(Registration Number) type long
A data member Cname of type string
A data member Agg_marks (Aggregate Marks) of type float
A data member Grade of type char
A member function setGrade ( ) to find the grade as per the aggregate marks obtained by the student. Equivalent aggregate marks range and the respective grade as shown below.

Aggregate Marks

 Grade

>=90  A
Less than 90 and >=75  B
Less than 75 and >=50  C
Less than 50  D

Public members:
A constructor to assign default values to data members:
A copy constructor to store the value in another object
Rno=0,Cname=”N.A” Agg_marks=0.0
A function Getdata ( ) to allow users to enter values for Rno.Cname, Agg_marks and call
functionsetGrade ( ) to find the grade.
A function dispResult( ) to allow user to view the content of all the data members.
A destructor to display the message “END”
Answer:
class student
{
long Rno;
char CName[20];
float Agg-Marks;
char Grade;
void setGrade( )
{
If (Agg_Marks>=90)
Grade = ‘A’;
else if (Agg_Marks<9.0 && Agg_Marks>=75)
Grade = ‘B’;
else if(Agg_Marks<75 && Agg_Marks>=50)
Grade = ‘C’;
else
Grade = ‘D’;
}
public:
candidate( )
{
Rno- 0;
Strcpy(CName , “N.A”);
Agg-Marks =0.0;
void Getdata( )
{
cout<<“Enter Register No”;
cih>>RNO;
cout<<“Enter CName”;
cin>>CName;
cout<<“A§gregate Marks”;
cin>>Agg_Marks;
setGrade( );
}
void dispResult( )
{
cout<<“Registration No”<<Rno;
cout<<“Name”«cname;
cout<<“Aggregate. Marks”<<Agg_Marks;
}
~student ( )
{
cout<<“END”;
}
};

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 53.
What are called members?
Answer:
Class comprises of members. Members are classified as Data Members and Member functions. Data members are the data variables that represent the features or properties of a class. Member functions are the functions that perform specific tasks in a class. Member functions are called as methods and data members are called as attributes.

Question 54.
Differentiate structure and class though both are user defined data type.
Answer:

Structure

 Class

In C++, a structure Can be referred to as an user defined data type possessing its own operations.  In C++, a class can be defined as a collection of related variables and functions encapsulated in a single structure.
Generally used for smaller amounts of data.  Generally used for large amounts of data.
The member variable of structure cannot be initialized directly.  The member variable of class can be initialised directly.

Question 55.
What is the difference between the class and object in terms of oop?
Answer:

class

 Object

A template or blueprint with which objects are Created is known as class.  An instance of a class is known as object.
It is declared by using class keyword.  It is invoked by new keyword.
The formation of a class doesn’t allocate memory. Creation of object consumes memory.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 56.
Why it is considered as a good practice to define a constructor though compiler can automatically generate a constructor?
Answer:

  1. When an object of the class is created, a compiler automatically generates a constructor if it is not defined.
  2. It is considered that writing constructor for a class is a good practice because constructor takes over very important duty of initialization of an object being created and relieves us from this task.

Question 57.
Write down the importance of destructor.
Answer:

  1. The purpose of the destructor is to free the resources that the object may have acquired during its lifetime.
  2. A destructor function removes the memory of an object which was allocated by the constructor at the time of creating a object.

Question 58.
Rewrite the following program after removing the syntax errors if any and underline the errors:
#include<iostream>
#include<stdio.h>
classmystud
{
intstudid =1001;
char name[20];
public mystud( )
{ }
void register ( )
{
cin>>studid;
gets(name);
}
void display ( )
{
cout<<studid<<“: “<<name<<endl;
}
int main( )
{
mystud MS;
register.MS( );
MS.dispfay( );
}
Answer:
#include<iOstream>
#include<stdio.h>
class mystud
{
int studid;
char name[20];
public:
mystud( )
{
Studid =1001;
}
void register( )
{
cin>>studid;
gets(name);
}
void display( )
{
cout<<studid<<“: “<<namd<<endl;
}
int main( )
{
mystud MS;
MS.register( );
MS.display( ) ;
}

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 59.
Write with example how will you dynamically initialize objects?
Answer:
When the initial values are provided during runtime, then it is called dynamic initialization.
Eg:
int main( )
{
int a;
float b;
cout<<“\n Enter the Roll . number”;
cin>>a;
cout<<“\h Entet the Avetage”;
cin>>b;
x x(a,b); //dynamic initialization
x.disp( );
return 0;

Question 60.
What are advantages of declaring constructors and destructor under public accessibility?
Answer:
The advantages of declaring under public accessibility, so that its object can be created in any function.

Question 61.
Given the following C++ code, answer the questions (i) & (ii)
class TestMeOut
{
public:
~TestMeOut( ) //Function 1
{cout<<“Leaving the examination hall”<<endl;
}
TestMeOut( )//Function 2
{cout<<“Appearingforexamination”<<endl;
}
void MyWork( )//Function 3
{
cout<<“Attempting Questions//<<endl;}
};

(i) In Object Oriented Programming, what is Function 1 referred as and when doesit get invoked / called ?
(ii) In Object Oriented Programming, what is Function 2 referred as and when doesit get invoked / called ?
Answer:
(i) Destructor: It is invoked as soon as the scope of the object of the class TestMeOut gets over.
(ii) Constructor: It is invoked automatically at the time of creation of the object of class TestMeOut.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 62.
Write the output of the following C++ program code :
#include<iostream>
using namespace std;
class Calci
{
char Grade;
int Bonus;
public:
Calci( )
{
Grade=’E’; Bonus=0;}//ascii value of
A=65
void Down(int G)
{
Grade-=G;
}
void Up(intG)
{
Grade+=G;
Bonus++;
}
Answer:
void Show( )
{
cout<<Grade<<“#”<<Bonus<<endl;
}
};
int main( ) ,
{
Calci c;
c.Down(3);
c.Show();
c.Up(7);
c.Show( );
c.Down(2);
c.Show( );
return 0;
}
Output:
B#0
I#1
G#1

Question 63.
Explain nested class with example.
Answer:
When a class is declared with in another class, the inner class is called as Nested class (i.e., the inner class) and the outer class is known as Enclosing class. Nested class can be defined in private as well as in the public section of the Enclosing class.
C++ program to illustrate the nested class:
#inelude<iostream>
using namespace std;
class enclose
{
private:
int X;
class nest
{
private :
int y;
public:
int z;
void prn( )
{
y=3; z=2
cout<<“\n The product of “<<y<< ‘ *’ <<z<<“=”<<y*z<<“\n”;
}
}; //inner class definition over
nest n1;
public:
nest n2;
void square( )
{
n2.prn( ); //inner class member function is called by its object
x=2;
n2.z=4;
cout<<“\n The product of “<<n2 . z <<‘*'<<n2 . z<<=<n2 . z*n2 . z <<“\n”;
cout<<“\n The product of ” <<x<< ‘*’ <<x<<“=”<<x*x;
}
}; //outer class definition over
int main( )
{
enclose e;
e.square ( ); //outer class member function is called
}
Output:
The product of 3*2=6
The product of 4*4=16
The product of 2*2=4
In the above program, the inner class nest is defined inside the outer class enclose. Nest is accessed by enclose by creating an object of nest.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 64.
Mention the differences between constructor and destructor.
Answer:

Constructor

 Destructor

A constructor is called when a new instance of a class is created.  A destructor is called when an existing instance of a class is destroyed.
It is called each time a class is instantiated.  It is called automatically when an object is deleted from the memory.
They can have arguments.  They gannot have arguments.
It allocates memory to a newly created object.  It deallocates memory of an object after its deletion.
There can be multiple constructors inside a class.  There can be only one destructor in a class.
It can be overloaded. The name of the constructor must be same as that of the class.  It cannot be overloaded. The destructor has the same name as that of the class prefixed by the tilde character.

Question 65.
Define a class RESORT with the following description in C++:
Private members:
Rno // Data member to store room number Name //Data member to store user name
Charges //Data member to store per day charge
Days //Data member to store the number of days
Compute ( ) // A function to calculate total amount as Days * Charges and if the
//total amount exceeds 11000 then total amount is 1.02 * Days *Charges

Public member:
getinfo( ) // Function to Read the information like name, room no, charges and days
dispinfo ( ) // Function to display all entered details and total amount calculated // using COMPUTE function
Answer:
Class RESORT
{
int Rno, Days;
char Name[30];
float charges;
float compute ( )
{
float temp = Days * charges;
if(temp >11000) .
return(1.02*temp);
}
Public:
void getinfo( )
{
cout<<“Enter the room number:
cin>>Rno;
cout<<“Enter the customer Name:” gets(Name);
cout<<“Enter the room charges per day:”;
cin>>charges;
cout<<“Enter number of days stayed by customer:”;
cin>>Days;
}
void dispinfo( )
{
cout<<“Room number: “«Rno; cout<<“Customer Name:” ;
puts (Name);
cout<<“Charges per day :” <<Charges;
cout<<“Number of days stayed by customer: “<<Days;
cout<<“Total charges of
customer: “<<compute ( ) ;
}
};

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 66.
Write the output of the following:
#include<iostream>
#include<stdio.h>
using namespace std;
class sub
{
int day, subno;
public:
sub(int,int); // prototype
void printsub( )
{
cout<<“subject number :”<<subno; cout<<“Days :”<<day;
}
};
sub::sub(int d=150,intsn=12)
{
cout<<endl<<“Constructing the object” <<endl;
day=d;
sub no=sn;
}
class stud
{
int rno;
float marks;
public:
stud( )
{
cout<<“Constructing the object of students” <<endl;
rno=0;
marks=0.0;
}
void getval( )
{
cout<<“Enter the roll number and the marks secured”;
cin>>rno>>marks;
}
void printdet( )
{cout<<“Roll no : “<<rno<<“Marks :”<<marks<<endl;
}
};
class admission
{
sub obj;
stud objone;
float fees;
public:
admission ( )
{
cout<< “Constructing the object of admission”<<endl;
fees=0.0;
}
void printdet( )
{
objone.printdet( );
obj.printsub();
cout<<“fees :”<<fees<,endl;
}
};
int main( )
{system(“cls”);
admission adm;
cout<<endl<< “Back in main ()”;
return 0;
}
Answer:
Output:
Constructing the object
Constructing the object of students
Constructing the object of admission
Back in main( )

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 67.
Write the output of the following.
#include<iostream>
#include<stdio.h>
using namespace std;
class P
{
public:
P( )
{
cout<< “\nConstructor of class P”;}
~P( )
{
cout<< “\nDestructor of class P”;}
class Q
{
public:
Q ( )
{
cout<<“\nConstructor of class Q”;
}
~Q( )
{cout<< “\nDestructor of class Q”;
}
};
class R
{
P obj1, obj2;
Q obj3;
public:
R( ) ,
{
cout<<“\nConstructor of class R”;}
~ R ( )
{
cout<< “\nDestructor of class R”;}
};
int main ( )
{
R Ro;
Q oq;
Pop;
return 0;
}
Answer:
Output:
Constructor of class P
Constructor of class P
Constructor of class Q
Constructor of class R
Constructor of class Q
Constructor of Class P
Destructor of class P
Destructor of class Q
Destructor of class R
Destructor of class Q
Destructor of class P
Destructor of class P

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Choose the correct answer:

Question 1.
________ is a way to bind the data and its associated functions together.
(a) Class
(b) Function
(c) Objects
(d) Variables
Answer:
(a) Class

Question 2.
The class body has access specifiers.
(a) two
(b) three
(c) four
(d) five
Answer:
(b) three

Question 3.
_________ is one of the important features of object oriented programming.
(a) Inheritance
(b) Encapsulation
(c) Data hiding
(d) Polymorphism
Answer:
(c) Data hiding

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 4.
The default access specifier for member is:
(a) public
(b) protected
(c) static
(d) private
Answer:
(d) private

Question 5.
Identify the odd:
(a) Public
(b) Protected
(c) Private
(d) Auto
Answer:
(d) Auto

Question 6.
The member functions of a class can be defined in ____ ways.
(a) two
(b) three
(c) four
(d) five
Answer:
(a) two

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 7.
Member functions are called as;
(a) data
(b) variables
(c) objects
(d) methods
Answer:
(d) methods

Question 8.
Data members are also called as:
(a) class
(b) objects
(c) attributes
(d) methods
Answer:
(c) attributes

Question 9.
_________ is a scope resolution operator.
(a) :
(b) ;
(c) .
(d) ::
Answer:
(d) ::

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 10.
Objects can be created in ______ methods.
(a) three
(b) five
(c) six
(d) two
Answer:
(d) two

Question 11.
_______ objects can be used by any function in the program.
(a) Local
(b) Auto
(c) Static
(d) Global
Answer:
(d) Global

Question 12.
________ objects cannot be accessed from outside the function.
(a) Protected
(b) Local
(c) Public
(d) Static
Answer:
(b) Local

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 13.
The members of a class are accessed by using ______ operator.
(a) :
(b) \
(c) ,
(d) .
Answer:
(d) .

Question 14.
An array which contains the class type of elements is called:
(a) array of objects
(b) array of elements
(c) array of classes
(d) array of functions
Answer:
(a) array of objects

Question 15.
Objects can be passed in ______ ways.
(a) three
(b) four
(c) two
(d) five
Answer:
(c) two

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 16.
If there are multiple variables with the same name defined in separate blocks then _________ operator will reveal the hidden file scope variable.
(a) &
(b) =
(C) >
(d) ::
Answer:
(d) ::

Question 17.
In ______ changes made to the object inside the function do not affect the original object.
(a) pass by value
(b) pass by object
(c) pass by reference
(d) pass by function
Answer:
(a) pass by value

Question 18.
In ______ any changes made to the object inside the function definition are reflected in original object.
(a) pass by class
(b) pass by object
(c) pass by reference
(d) pass by value
Answer:
(c) pass by reference

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 19.
When one class become the member of another class then it is called:
(a) Nested function
(b) Nested objects
(c) Nested class
(d) Nested structure
Answer:
(c) Nested class

Question 20.
When an instance of a class comes into scope, a special function called the _______ gets executed.
(a) constructor
(b) nested function
(c) destructor
(d) structure
Answer:
(a) constructor

Question 21.
The constructor function name has the same name as the ______ name.
(a) function
(b) object
(c) class
(d) array
Answer:
(c) class

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 22.
If a class does not contain an user defined constructor compiler automatically generates ______ constructor.
(a) copy
(b) abstract
(c) default
(d) destructor
Answer:
(c) default

Question 23.
A constructor which can take arguments is called _______ constructor.
(a) default
(b) copy
(c) abstract
(d) parameterized
Answer:
(d) parameterized

Question 24.
________ constructor helps to create objects with different initial values.
(a) First
(b) Parameterized
(c) Instance
(d) Copy
Answer:
(b) Parameterized

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 25.
Constructors are advisable to define in __________ section of a class.
(a) private
(b) protected
(c) public
(d) default
Answer:
(c) public

Read the code below and answer the questions 26 and 27.
class simple
{
Private: int x;
public: simple(int y)
{
x = y;
}
~ simple( )
{
}
};

Question 26.
The name of the constructor is:
(a) simple
(b) simple
(c) private
(d) public
Answer:
(a) simple

Question 27.
What type of constructors are used in the above code?
(a) Non – parameterized
(b) Copy
(c) Parameterized
(d) Default
Answer:
(c) Parameterized

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 28.
There are ________ ways to Create an object using parameterized constructor.
(a) three
(b) two
(c) four
(d) five
Answer:
(b) two

Question 29.
An _____ to constructor creates temporary instance in the memory.
(a) implicit call
(b) explicit call
(c) copy
(d) object
Answer:
(b) explicit call

Question 30.
A constructor having a reference to an already existing object of its own class is called:
(a) call by reference
(b) default constructor
(c) copy constructor
(d) abstract
Answer:
(c) copy constructor

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 31.
add(add & a) is a _________ constructor.
(a) copy
(b) abstract
(c) default
(d) parameterized
Answer:
(a) copy

Question 32.
Whieh of the following is not true?
(a) The name of the constructor must be same as that of the class.
(b) No return type can be specified for constructor.
(c) A constructor can have parameter list.
(d) The constructor function cannot be overloaded.
Answer:
(d) The constructor function cannot be overloaded.

Question 33.
When a class object goes out of seope, ______ gets executed.
(a) destructor
(b) constructor
(c) default constructor
(d) copy constructor
Answer:
(a) destructor

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 34.
The destructor is prefixed by:
(a) *
(b) ~
(c) +
(d) –
Answer:
(b) ~

Question 35.
Which of the following are not provided by the compiler by default?
(a) Zero-argument constructor
(b) Destructor
(c) Copy constructor
(d) Copy destructor
Answer:
(c) Copy constructor

Question 36.
A _______ is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.
(a) default constructor
(b) copy constructor
(c) Both (a) and (b)
(d) None of these
Answer:
(a) default constructor

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 37.
How many default constructors per class are possible?
(a) Only one
(b) Two
(c) Three
(d) Uilimited
Answer:
(a) Only one

Question 38.
Which of the following statement is correct about destructors?
(a) A destructor type. has void return
(b) A destructor type. has integer return
(c) A destructor has no return type.
(d) A destructors return type is always same as that of main( ).
Answer:
(c) A destructor has no return type.

Question 39.
Which of the following never requires any argument?
(a) Member function
(b) Friend function
(c) Default constructor
(d) Const function
Answer:
(c) Default constructor

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 40.
Which of the following statements are correct?
(a) Constructor is always called explicitly.
(b) Constructor is called either implicitly or explicitly, where as destructor is always called implicitly.
(c) Destructors is always called explicitly.
(d) Constructor and destructor functions are not ealled at all as they are always inline.
Answer:
(b) Constructor is called either implicitly or explicitly, where as destructor is always called implicitly.

Question 41.
Identify the default constructor?
(a) add( )
(b) add(int s1)
(c) add(int s1, int s2)
(d) add(add & a)
Answer:
(a) add( )

Read the following code and answer the questions 42 & 43.
class simple
{
private: int x;
public: simple(int y)
{
x=y;
}
};
void main ( )
{
Simple s(6) ;
}

Question 42.
How many objects are created?
(a) 0
(b) 7
(c) 1
(d) 6
Answer:
(d) 6

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 43.
What type of constructors are used in the above program?
(a) Parameterized constructor
(b) Copy constructor
(c) Non- parameterized constructor
(d) Default constructor
Answer:
(a) Parameterized constructor

Question 44.
Which of the following two entities can be connected by the dot operator?
(a) A class member and a class object.
(b) A class object and a class.
(c) A class and a member of that class-
(d) A class object and a member of that class.
Answer:
(d) A class object and a member of that class.

Question 45.
Which of the following statements is correct about the constructors and destructors?
(a) Destructors can take arguments but constructors cannot.
(b) Constructors can take arguments but destructors cannot.
(c) Destructors can be overloaded but constructors cannot be overloaded.
(d) Constructors can return a value.
Answer:
(b) Constructors can take arguments but destructors cannot.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 46.
Which of the following access specifiers is used in a class definition by default?
(a) Protected
(b) Public
(c) Private
(d) Friend
Answer:
(c) Private

Question 47.
_______ provides additional benefit to access the child classes.
(a) Default
(b) Break
(c) Protected
(d) Private
Answer:
(c) Protected

Question 48.
Which of the following ean access private data members or member functions of a class?
(a) Any function in the program.
(b) All global functions in the program.
(c) Any member function of that class.
(d) Only public member functions of that class.
Answer:
(c) Any member function of that class.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 49.
Which of the following statements is correct?
(a) Data items in a class must be private.
(b) Both data and functions can be either private or public.
(c) Member functions of a class must be private.
(d) Constructor of a class cannot be private
Answer:
(b) Both data and functions can be either private or public.

Question 50.
Where does the object is created?
(a) Class
(b) Constructor
(c) Destructor
(d) Attributes
Answer:
(a) Class

Question 51.
Match the following:

(i) Member function  (a) attributes
(ii) Data Members  (b) instance of a class
(iii) Object  (c) allocate memory space to object
(iv) Constructor  (d) methods

(a) (i) – (d); (ii) – (a); (iii) – (b); (iv) – (c)
(b) (i) – (a); (ii) – (b); (iii – (c); (iv) – (d)
(c) (i) – (b); (ii) – (a); (iii) – (d); (iv) – (c)
(d) (i) – (c); (ii) – (d); (iii) – (b); (iv) – (a)
Answer:
(a) (i) – (d); (ii) – (a); (iii) – (b); (iv) – (c)

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 52.
Match the following:

(i) Test ( )  (a) Copy constructor
(ii) Test(int x int y)  (b) Method
(iii) Void show( )  (c) Default constructor
(iv) Test (test & a)  (d) Parametarized constructor

(a) (i) – (b); (ii) – (c); (iii) – (d); (iv) – (a)
(b) (i) – (c); (ii) – (d); (iii) – (a); (iv) – (b)
(c) (i) – (b); (ii) – (c); (iii) – (a); (iv) – (d)
(d) (i) – (c); (ii) – (d); (iii) – (b); (iv) – (a)
Answer:
(d) (i) – (c); (ii) – (d); (iii) – (b); (iv) – (a)

Question 53.
Identify the correct statement:
(a) In constructor overloading is not allowed.
(b) It is executed when an object is destroyed.
(c) It allocates memory space to objects.
(d) It cannot have argument.
Answer:
(c) It allocates memory space to objects.

Question 54.
Identify the Incorrect statement:
(a) :: operator will reveal the hidden file scope variable.
(b) A member function can access only the private function.
(c) When a class is declared with in another class, the inner class is called as nested class.
(d) The destructors are prefixed by tilde character
Answer:
(b) A member function can access only the private function.

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 55.
Assertion (A):
A constructor having a reference to an already existing object of its own class is called copy constructor.
Reason (R):
The argument should be passed only by reference not by value method.
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true, but R is not the correct explanation for A.
(c) A is true, but R is false.
(d) A is false, but R is true.
Answer:
(a) Both A and R are true and R is the correct explanation for A.

Question 56.
The variables declared inside the class are known as data members and the functions are known as:
(a) data functions
(b) inline functions
(c) member functions
(d) attributes
Answer:
(c) member functions

Question 57.
Which of the following statements about member functions are True or False?
(i) A member function can call another member function directly with using the dot operator.
(ii) Member function can access the private data of the class.
(a) (i) -True, (ii) – True
(b) (i) – False, (ii) – True
(c) (i) – True, (ii) – False
(d) (i) – False, (ii) – False
Answer:
(b) (i) – False, (ii) – True

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 58.
A member function can call another member function directly, without using the dot operator called as:
(a) sub function
(b) sub member
(c) nesting of member function
(d) sibling of member function
Answer:
(c) nesting of member function

Question 59.
The member function defined within the class behave like:
(a) inline functions
(b) non-inline function
(c) outline function
(d) data function
Answer:
(a) inline functions

Question 60.
Which of the following access specifier
(a) Private
(b) Protected
(c) Public
(d) Global
Answer:
(a) Private

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 61 .
class x
{
int y;
public:
x(int z)(y=z;}
} x1[4];
int main( )
{
x x2(10);
return 0;
}
How many objects are created for the above program?
(a) 10
(b) 14
(c) 5
(d) 2
Answer:
(c) 5

Question 62.
State whether the following statements about the constructor are True or False.
(i) constructors should be declared in the private section.
(ii) constructors are invoked automatically when the objects are created.
(a) True, True
(b) True, False
(c) False, True
(d) False, False
Answer:
(c) False, True

Question 63.
Which of the following constructor is executed for the following prototype?
add displayf add &); // add is a class name
(a) Default constructor
(b) Parameterized constructor
(c) Copy Constructor
(d) Non-Parameterized constructor
Answer:
(c) Copy Constructor

Samacheer Kalvi TN State Board 11th Computer Applications Important Questions Chapter 14 Classes and Objects

Question 64.
What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero- argument constructor?
(a) Compile-time error
(b) Domain error
(c) Runtime error
(d) Runtime exception.
Answer:
(a) Compile-time error

Question 65.
Which of the following Create a temporary instance?
(a) Implicit call to the constructor
(b) Explicit call to the constructor
(c) Implicit call to the destructor
(d) Explicit call to the destructor
Answer:
(b) Explicit call to the constructor

TN Board 11th Computer Science Important Questions