11th Standard Syllabus & Materials
11th Standard
TN 11th English Supplementary - 3 - The First Patient (Play) Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th English Prose - 3 - Forgetting Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th English Prose - 2 - The Queen of Boxing Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th English Poem - 1 - Once Upon A Time Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th English Prose - 1 - The Portrait of a Lady Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th Computer Applications Tamil Computing Sample Question Papers Study Material - QB365 Set A

Published on: 09/09/2019
Classes and Objects
Download Tamil Nadu 11th Standard Computer Science question papers, model tests, one-mark questions, important questions, and public exam papers in PDF format. Free study materials and answer keys for TN State Board students.
Questions + Answers key
Take MCQ Computer Science Test

1.
Write down the importance of destructor.
2.
Why it is considered as a good practice to define a constructor though compiler can automatically generate a constructor?
3.
What is the difference between the class and object in terms of oop?
4.
Write the output of the following C++ program code :
#include
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(int G)
{
Grade+=G;
Bonus++;
}
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;
}
5.
What are advantages of declaring constructors and destructor under public accessability?
6.
Write with example how will you dynamically initialize objects?
7.
Mention the differences between constructor and destructor.
8.
Explain nested class with example.
9.
Which of the following create a temporary instance?
Implicit call to the constructor
Explicit call to constructor
Implicit call to the destructor
Explicit call to the destructor
10.
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?
Compile-time error
Domain error
Runtime error
Runtime exception
11.
Which of the following constructor is executed for the following prototype?
add display (add &): - // add is a class name
Default constructor
Parameterized constructor
Copy constructor
Non Parameterized constructor
12.
The member function defined within the class behave like________functions.
inline
Non inline
Outline
Data
13.
The variables declared inside the class are known as
data
inline
method
attributes
1.
The purpose of the destructor is to free the resources that the object may have acquired during its lifetime. A destructor function removes the memory of an object which was allocated by the constructor at the time of creating a object.
2.
Declaring a constructor with arguments hides the compiler generated constructor. After this we cannot invoke the compiler generated constructor.
3.
| Class | Object |
|---|---|
| Class is a blueprint or template from which objects are created. | Object is an instance of class |
| Class is a group of similar objects. | Object is a real world entity such as pen, laptop, mobile, chair etc. |
| Class doesn't allocate memory when it is created. | Object allocates memory when it is created. |
4.
B # 0
I # 1
G # 1
5.
When constructor and destructor are declared under public:
1. we can initialize the object while declaring it.
2. we can explicitly call the constructor.
3. we can overload constructors and therefore use multiple constructors to initialize objects automatically.
4. we can destroy the objects at the end of the class scope automatically (free unused memory).
However, some C++ compilers and Dev C++ do not allow to declare constructor and destructors under private section. So it is better to declare constructor and destructor under public section only.
6.
When the initial values are provided during runtime then it is called dynamic initialization.
Example to illustrate dynamic initialization
#include < iostream >
using namespace std;
class X
{
int n;
float avg;
public;
X(int p,float q)
{
n=p;
avg=q;
}
void disp( )
{
cout << "\n Roll number:-"<< n;
}
};
int main( )
{
int a; float b;
cout<< "\nEnter the Roll number";
cin >> a;
cout << "\nEnter the Average";
cin >> b;
X x(a,b);\\dynamic initialization
x.disp( );
return 0;
}
Output:
Enter the Roll Number 1201
Enter the Average 98.6
Roll number:- 1201
Average:- 98.6
7.
| Constructor | Destructor |
|---|---|
| The name of the constructor must be same as that of the class. | The destructor has the same name as that of the class prefixed by the tilde character '~'.. |
| No return type can be specified for constructor. | It has no return type. |
| A constructor can have parameter list. | The destructor cannot have arguments |
| The constructor function can be overloaded. | Destructors cannot be overloaded i.e., there can be only one destructor in a class. |
| They cannot be inherited but a derived class can call the base class constructor. | They cannot be inherited. |
| The compiler generates a constructor, in the absence of a user defined constructor. | In the absence of user defined destructor, it is generated by the compiler. |
8.
Nested class: 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.
Defining a class with in another: When a class is declared with in another class, the inner class is called as Nested class (ie 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
#include < 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 objec of nest.
9.
(b)
Explicit call to constructor
10.
(a)
Compile-time error
11.
(c)
Copy constructor
12.
(a)
inline
13.
(c)
method
11th Standard Syllabus & Materials
11th Standard
TN 11th Computer Applications Computer Ethics and Cyber Security Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th Computer Applications JavaScript Functions Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th Computer Applications Control Structure in JavaScript Sample Question Papers Study Material - QB365 Set A
NEW11th Standard
TN 11th Computer Applications Introduction to JavaScript Sample Question Papers Study Material - QB365 Set A
Tamilnadu Stateboard 11th Standard Subjects

Maths

Commerce

Economics

Biology

Business Maths and Statistics

Accountancy

Computer Science

Physics

Chemistry

Maths

Biology

Economics

Physics

Chemistry

History

Business Maths and Statistics

Computer Science

Accountancy

Computer Applications

History

Computer Technology

Commerce

Computer Applications

Computer Technology

Tamil

English

French
Tamilnadu Stateboard Standards