Object Oriented Programming interview questions part 10

Object Oriented Programming interview questions part 10

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

Total Questions: 20

1. If the object is passed by value to a copy constructor:

Correct Answer is : Compiler will give out of memory error

2. Which object will be created first? class student { int marks; }; student s1, s2, s3;

Correct Answer is : s1 then s2 then s3

3. Which among the following helps to create a temporary instance?

Correct Answer is : Explicit call to a constructor

4. Which among the following is correct for the class defined below? class student { int marks; public: student(){} student(int x) { marks=x; } }; main() { student s1(100); student s2(); student s3=100; return 0;

Correct Answer is : Program runs and all objects are created

5. For constructor overloading, each constructor must differ in ___________ and __________

Correct Answer is : Number of arguments and type of arguments

6. Which among the following is true for constructors overloading?

Correct Answer is : Constructors can be overloaded using different signatures

7. If a constructors should be capable of creating objects without argument and with arguments, which is a good alternative for this purpose?

Correct Answer is : Use constructor with all default arguments

8. The Constructors with all the default arguments are similar as default constructors. (True/False)

Correct Answer is : TRUE

9. Which among the following is true?

Correct Answer is : The constructors must have same name as that of class

10. Which among the following can be used in place of default constructor?

Correct Answer is : constructorName(int x=0,int y=0)

11. Can a class have more than one function with all the default arguments?

Correct Answer is : No, never

12. Which is the correct syntax for using default arguments with the constructor?

Correct Answer is : constructorName(int x=0)

13. How many parameters must be passed if only the following prototype is given to a constructor? Prototype: className(int x, int y, int z=0);

Correct Answer is : 2

14. If the constructors are overloaded by using the default arguments, which problem may arise?

Correct Answer is : The constructors might have all the same arguments except the default arguments

15. Which among the following is true?

Correct Answer is : More than one constructors with all default arguments can’t exist in same class

16. Which constructor among the following will be called if a call is made like className(5,’a’);?

Correct Answer is : className(int x=5,char c=’a’);

17. Which constructor definition will produce a compile time error?

Correct Answer is : className(int x=0,char c);

18. If there is a constructor with all the default arguments and arguments are not passed then _________________

Correct Answer is : Then all the default values given will be used

19. Which is the correct statement for default constructors?

Correct Answer is : The constructors with zero arguments

20. Which is a good alternative instead of having one zero argument constructor and one single argument constructor with default argument?

Correct Answer is : One default value constructor

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon