Object Oriented Programming interview questions part 12
Object Oriented Programming interview questions part 12
Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. How to access data members of a class?
Correct Answer is : Dot or arrow as required
2. To create a pointer to a private data member of a class, outside the class, which among the following is correct?
Correct Answer is : Return the address of the private data member using a member function
3. Which among the following is true for use of setter() and getter() function?
Correct Answer is : Considered a red flag, and not recommended for large scale use
4. What is the output of following code?
int n=10; // global
class A()
{
private : int n;
public : int m;
A()
{
n=100; m=50;
}
void disp()
{
cout<<”n”<
Correct Answer is : n50100
5. The static member functions can only use ________
Correct Answer is : Static data members
6. A class can have self-referential data members.
Correct Answer is : FALSE
7. What is the keyword used to make data members have same value?
Correct Answer is : const
8. Which data members can be inherited but are private to a class?
Correct Answer is : Protected
9. The arguments passed to member functions by reference are considered as data members of class.
Correct Answer is : FALSE
10. Which among the following is not allowed for data member declaration?
Correct Answer is : abstract a;
11. What are default arguments?
Correct Answer is : Arguments with default value that aren’t mandatory to be passed
12. Which is correct condition for the default arguments?
Correct Answer is : Those must be declared as last arguments in argument list
13. If a member function have to be made both zero argument and parameterized constructor, which among the following can be the best option?
Correct Answer is : Make all the arguments default
14. Which among the following function can be called without arguments?
Correct Answer is : void add(int x=0, int y=0)
15. If a function have all the default arguments but still some values are passed to the function then ______________
Correct Answer is : The function will use the values passed to it
16. Which among the following is correct?
Correct Answer is : void test(int x,int y=0)
17. What function will be called with the independent syntax “test(5,6,7);”?
Correct Answer is : void test(int x,int y, int z=0)
18. Which among the following is wrong call to the function void test(int x, int y=0, int z=0)?
Correct Answer is : test();
19. Default arguments are _________________________
Correct Answer is : Only allowed in the parameter list of the function declaration
20. Which among the following is false for default arguments?
Correct Answer is : Those are allowed with pointer and reference to function declaration