| Snaprecruit.com

| Snaprecruit.com

Interview question based on skill :

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. If a const object calls a non-const member function then ____________________

Correct Answer is : Compile time error may get produced

2. Can a constructor function be constant?

Correct Answer is : No, never

3. A function can have both the const and non-const version in the same program.

Correct Answer is : TRUE

4. How is it possible to have both const and non-const version of a function?

Correct Answer is : Function overloading

5. When both the const and non-const version of a functions are required?

Correct Answer is : Return value have to be different in const

6. If a function is to be made const, which is the correct syntax?

Correct Answer is : const returnType functionName(parameters);

7. Functions which differ in const-ness are considered ______________________

Correct Answer is : To have different signature

8. If const version of a function when overloading is used, the function ___________________

Correct Answer is : Returns const reference

9. Which among the following is recommended for const functions?

Correct Answer is : Const function use should be more in a program

10. Use of const member function in a program _________________________

Correct Answer is : Is optional, always

11. Which among the following is called first, automatically, whenever an object is created?

Correct Answer is : Constructor

12. Which among the following is not a necessary condition for constructors?

Correct Answer is : It must contain a definition body

13. Which among the following is correct?

Correct Answer is : class student{ public: student(){} };

14. In which access should a constructor be defined, so that object of the class can be created in any function?

Correct Answer is : Public

15. How many types of constructors are available for use in general (with respect to parameters)?

Correct Answer is : 2

16. If a programmer defines a class and defines a default value parameterized constructor inside it. He has not defined any default constructor. And then he try to create the object without passing arguments, which among the following will be correct?

Correct Answer is : It will create the object (as the default arguments are passed )

17. Default constructor must be defined, if parameterized constructor is defined and the object is to be created without arguments.

Correct Answer is : TRUE

18. If class C inherits class B. And B has inherited class A. Then while creating the object of class C, what will be the sequence of constructors getting called?

Correct Answer is : Constructor of A then B, finally C

19. In multiple inheritance, if class C inherits two classes A and B as follows, which class constructor will be called first: class A{ }; class B{ }; class C: public A, public B{ };

Correct Answer is : A()

20. Which among the following is true for copy constructor?

Correct Answer is : It can be defined with zero arguments