MABS Institution
11th Computer Science Monthly Test -1 ( Classes and objects )-Aug 2020
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Define class
-
List the features of oop language.
-
What is access specifies?
-
How the members of a class referenced?
-
Give an example of declaring destructor for class sample.
-
Differentiate implicit call and explicit call of involving parameterized constructor.
-
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 >> stdid;gets(name);
}
void display ( )
{ cout << studid << ":" << name << endl; }
}
int main( )
{ mystud MS;
register.MS( );
MS.display( );
} -
Write with example how will you dynamically initialize objects?
-
What is inline and outline member function?
-
-
What is copy constructor?
-
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;
}
-
-
What are advantages of declaring constructors and destructor under public accessability?
-
When a copy constructor is called?
-
Write a short note on memory allocation of objects.
-
Given the following C++ code, answer the questions (i) & (ii).
class TestMeOut
{
public:
~TestMeOut() //Function 1
{cout<< “Leaving the examination hall”< TestMeOut() //Function 2
{cout<< “Appearing for examination”< void MyWork() //Function 3
{cout<< “Attempting Questions//< };
(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 ? -
Write the output of the following program.
-
Mention the differences between constructor and destructor
-
Write the output of the following program.
-
Explain how the objects can be passed in pass by value method.
-
Explain the different methods of creating an object in C++
-
-
Write the output of the following program
-
Explain the types of access specifiers used in C++
-
-
Write a C++ program to find square and cube of a number showing the use of nesting of members functions.
-
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 ( )
{
Ro R;
Q oq;
P op;
return 0;
} -
Write a C++ program example of creating global and local object