NewsTicker

C++ Quiz


Online Examination for C++ Language Quiz Question And Answer





Online Test


1. A constructor that accepts __________ parameters is called the default constructor.

one
two
no
three
-----------------------------------------------------------------------------------------------------------------
2. 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
Preprocessing error
Runtime error.
Runtime exception
-----------------------------------------------------------------------------------------------------------------
3. Can a class have virtual destructor?

yes
no
may be
all the above
-----------------------------------------------------------------------------------------------------------------
4. Destructor has the same name as the constructor and it is preceded by ______ .

!
?
~
$
-----------------------------------------------------------------------------------------------------------------
5. For automatic objects, constructors and destructors are called each time the objects

enter and leave scope
inherit parent class
are constructed
are destroyed
-----------------------------------------------------------------------------------------------------------------
6. Which constructor function is designed to copy objects of the same class type?

Create constructor
Object constructor
Dynamic constructor
Copy constructor
-----------------------------------------------------------------------------------------------------------------
7. Which of the following statement is correct?

Constructor has the same name as that of the class
Destructor has the same name as that of the class with a tilde symbol at the beginning.
Both A and B
Destructor has the same name as the first member function of the class.
-----------------------------------------------------------------------------------------------------------------
8. Destructor has the same name as the first member function of the class.

Constructor is a member function of the class
The compiler always provides a zero argument constructor
It is necessary that a constructor in a class should always be public.
Both B and C
-----------------------------------------------------------------------------------------------------------------
9. When are the Global objects destroyed?

When the control comes out of the block in which they are being used.
When the program terminates
When the control comes out of the function in which they are being used.
As soon as local objects die.
-----------------------------------------------------------------------------------------------------------------
10. Copy constructor must receive its arguments by __________ .

either pass-by-value or pass-by-reference
only pass-by-value
only pass-by-reference
only pass by address
-----------------------------------------------------------------------------------------------------------------
11. Which of the following function prototype is perfectly acceptable?

int Function(int Tmp = Show());
float Function(int Tmp = Show(int, float));
Both A and B.
float = Show(int, float) Function(Tmp);
-----------------------------------------------------------------------------------------------------------------
12. Which of the following statement is correct?

C++ enables to define functions that take constants as an argument.
We cannot change the argument of the function that that are declared as constant.
Both A and B.
We cannot use the constant while defining the function
-----------------------------------------------------------------------------------------------------------------
13. Which of the following statement is correct?

Overloaded functions can have at most one default argument.
An overloaded function cannot have default argument
All arguments of an overloaded function can be default
function if overloaded more than once cannot have default argument.
-----------------------------------------------------------------------------------------------------------------
14. Which of the following statement is correct?

Two functions having same number of argument, order and type of argument can be overloaded if both functions do not have any default argument.
Overloaded function must have default arguments
Overloaded function must have default arguments starting from the left of argument list.
A function can be overloaded more than once
-----------------------------------------------------------------------------------------------------------------
15. Which of the following statement will be correct if the function has three arguments passed to it?

The trailing argument will be the default argument
The first argument will be the default argument
The middle argument will be the default argument
All the argument will be the default argument.
-----------------------------------------------------------------------------------------------------------------
16. Which of the following statement is incorrect?

Default arguments can be provided for pointers to functions
A function can have all its arguments as default.
Default argument cannot be provided for pointers to functions.
A default argument cannot be redefined in later declaration.
-----------------------------------------------------------------------------------------------------------------
17. Which of the following statement is correct?

Constructors can have default parameters.
Constructors cannot have default parameters
Constructors cannot have more than one default parameter
Constructors can have at most five default parameters.
-----------------------------------------------------------------------------------------------------------------
18. Which of the following function / type of function cannot be overloaded?

Member function
Static function
Virtual function
Both B and C
-----------------------------------------------------------------------------------------------------------------
19. Which of the following function declaration is/are incorrect?

int Sum(int a, int b = 2, int c = 3);
int Sum(int a = 5, int b);
int Sum(int a = 0, int b, int c = 3);
Both B and C are incorrect
-----------------------------------------------------------------------------------------------------------------
20. Which of the following statement is incorrect?

The default value for an argument can be a global constant.
The default arguments are given in the function prototype
Compiler uses the prototype information to build a call, not the function definition.
The default arguments are given in the function prototype and should be repeated in the function definition.
-----------------------------------------------------------------------------------------------------------------
21. Which of the following statement is correct?

A reference is stored on heap.
A reference is stored on stack.
A reference is stored in a queue.
A reference is stored in a binary tree
-----------------------------------------------------------------------------------------------------------------
22. Which of the following statements is correct?Once a reference variable has been defined to refer to a particular variable it can refer to any other variable.A reference is not a constant pointer 

Only 1 is correct.
Only 2 is correct.
Both 1 and 2 are correct.
Both 1 and 2 are incorrect.
-----------------------------------------------------------------------------------------------------------------
23. Which of the following type of class allows only one object of it to be created?

Virtual class
Abstract class
Singleton class
Friend class
-----------------------------------------------------------------------------------------------------------------
24. Which of the following is not a type of constructor?

Copy constructor
Friend constructor
Default constructor
Parameterized constructor
-----------------------------------------------------------------------------------------------------------------
25. Which of the following statements is incorrect?

Friend keyword can be used in the class to allow access to another class.
Friend keyword can be used for a function in the public section of a class.
Friend keyword can be used for a function in the private section of a class.
Friend keyword can be used on main().
-----------------------------------------------------------------------------------------------------------------
Score =
Correct answers: