Object- Oriented Programming Interview Questions - 40 | Snaprecruit.com

Object- Oriented Programming Interview Questions - 40 | Snaprecruit.com

Object Oriented Programming interview questions part 40

Object Oriented Programming interview questions part 40

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

Total Questions: 20

1. If 2 classes derive one base class and redefine a function of base class, also overload some operators inside class body. Among these two things of function and operator overloading, where is polymorphism used?

Correct Answer is : Either function overloading or operator overloading because polymorphism can be applied only once in a program

2. If a function has to be called only by using other member functions of the class, what should be the access specifier used for that function?

Correct Answer is : Private

3. Which among the following is correct for the code given below? class student { private: student() { } public : student( int x) { marks =x; } };

Correct Answer is : Only the object with only 1 parameter can be created

4. Which among the following is true for the code given below? class A { private : int marks; char name[20]; public : A(int x=100) { marks=x; } };

Correct Answer is : Objects can be created with one parameter or without parameter

5. Which among the following is correct to call a private member from outside the class?

Correct Answer is : Not possible

6. If private members has to be accessed directly from outside the class but the access specifier must not be changed, what should be done?

Correct Answer is : Friend function should be used

7. Which access specifier is/are most secure during inheritance?

Correct Answer is : Private

8. Choose the correct option for the code given below class A{ static int c=0; public: A(){ c++; } };

Correct Answer is : Constructor will keep number of objects created

9. Which option is false for the following code? class A { private : int sum(int x, int y) { return x+y; } public: A() { } A(int x, int y) { cout<<sum(x,y); } };

Correct Answer is : Constructor will take 0 as default value of parameters if not passed

10. Which member will never be used from the following class? class A() { int marks; char name[20]; public : A() { marks=100; } void disp() { cout<<”Marks= ”<'<marks; cout<<”Student”; } };

Correct Answer is : name variable will never be used

11. Private member functions can be overloaded.

Correct Answer is : TRUE

12. Which among the following is true?

Correct Answer is : Private member function can’t be overridden

13. Which data member in following code will be used whenever an object is created? Class A { int x; int y; int z; public : A() { y=100; x=100*y; } };

Correct Answer is : z will be used

14. Which member can be considered most secure in the code below? class A() { int a; private : int b; protected : int c; public : int d; };

Correct Answer is : b

15. Which among the following is correct for the code given below? class A { private : A() { } public : A(int x) { } }; A a; A b(100);

Correct Answer is : Program will give compile time error

16. Which among the following is correct?

Correct Answer is : Private specifier can be used anywhere in class

17. Which is private member functions access scope?

Correct Answer is : Member functions which can only be used within the class

18. Which among the following is true?

Correct Answer is : The private members can be accessed by public members of the class

19. Which member can never be accessed by inherited classes?

Correct Answer is : Private member function

20. Which syntax among the following shows that a member is private in a class?

Correct Answer is : private functionName(parameters)

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon