Professional Documents
Culture Documents
When the private keyword is used to define a function or class, it becomes private. Such are only
accessible from within the class.
Public:
The public keyword, on the other hand, makes data/functions public. These are accessible from
outside the class.
Object Definition:
Objects are created from classes. Class objects are declared in a similar way as variables are
declared. The class name must start, followed by the object name. The object of the class type.
A) ~ B) ! c)& D) $
For automatic objects, constructors and destructors are called each time the objects ……..
1) enter and leave scope
3)are constructed
4)are destroyed
-A function with the same name as the class, but preceded with a tilde character (~) is called
destructor of that class.
-Which of the following gets called when an object goes out of scope? Destructor
Which of the following gets called when an object is being created? Constructor
Q- Find output
int n=5 ;
while (n>0)
{
cout << n << ", ";
--n;
}
cout << "FIRE!\n";
5, 4, 3, 2, 1, Fire!
Q- Find output
int n=5;
do {
cout << n << ", ";
--n;
} while (n<0);
cout << "FIRE!\n";
5 ,Fire!
Q- Chose correct
int arr[5]=10},13,14,20,19{;
int avg , sum=0;
for (int i=0; i<5 ; i++)
}
sum+=arr[i];
{
avg=sum/5;
cout<<avg;
Q- Chose correct
int arr[5]=10},13,14,20,19{;
float avg , sum=0;
for (int i=0; i<5 ; i++)
}
sum+=arr[i];
{
avg=sum/5;
cout<<avg;
Notes :