MCQ On Classes And Objects - C++ Programming

25. What will be the output of the following program?
Note:Includes all required header files

class find
{
static int x;
public:
static void Set(int xx)
{
x = xx;
}
void Display()
{
cout<< x ;
}
};
int find::x = 0;
int main()
{
find::Set(33);
find::Display();
return 0;
}

A. The program will print the output 0.
B. The program will print the output 33.
C. The program will print the output Garbage.
D. The program will report compile time error.

View Answer


26. What will be the output of the following program?
Note:Includes all required header files

class course
{
int x, y;
public:
course(int xx)
{
x = ++xx;
}
void Display()
{
cout<< --x << " ";
}
};
int main()
{
course obj(20);
obj.Display();
int *p = (int*)&obj ;
*p = 5;
obj.Display();
return 0;
}

A. 20 4
B. 21 4
C. 20 5
D. 21 5

View Answer


27. Which of the following statements is correct when a class is inherited publicly?

A. Public members of the base class become protected members of derived class.
B. Public members of the base class become private members of derived class.
C. Private members of the base class become protected members of derived class.
D. Public members of the base class become public members of derived class.

View Answer


28.What does the cerr represent?

A. Standard error stream
B. Standard logging stream
C. Input stream
D. Output stream

View Answer


29.Which of the following keywords is used to control access to a class member?

A. Default
B. Break
C. Protected
D. Asm

View Answer


30.Which of the following statements is incorrect?

A. Destructor of base class should always be static
B. Destructor of base class should always be virtual.
C. Destructor of base class should not be virtual.
D. Destructor of base class should always be private.

View Answer


31. Which operator can not be overloaded?

A. +
B. ::
C. -
D. *

View Answer


32. When Virtual Table is created?

A. Every Class has VTable
B. Class inherited from other Class
C. Class has atleast one Virtual Function
D. When a Class Overrides the function of Base class

View Answer


33. What is the size of empty class?

A. 0
B. 2
C. 4
D. 1

View Answer






Also check :


Discussion


* You must be logged in to add comment.