1. If class B inherits class A privately. And class B has a friend function. Will the friend function be able to access the private member of class A?
Correct Answer is : No, because friend function can only access private members of friend class
2. If an abstract class has all the private members, then _________
Correct Answer is : No class will be able to implement members of abstract class
3. Which access specifier should be used so that all the parent class members can be inherited and accessed from outside the class?
Correct Answer is : Public
4. Which access specifier is usually used for data members of a class?
Correct Answer is : Private
5. Which specifier should be used for member functions of a class?
Correct Answer is : Public
6. When value of an object is assigned to another object, ___________________
Correct Answer is : Its values gets copied into another object
7. If an object is created and another object is assigned to it, then ________________
Correct Answer is : Reference to another object is created
8. How the argument passed to a function get initialized?
Correct Answer is : Assigned using copy constructor at time of passing
9. Predict the output of the program.
class A
{
public int i;
};
void main()
{
A x;
A y=x;
x.i=10;
y.i=20;
y.i++;
y.i=20;
cout&l;<tx.i;
}
10. If programmer doesn’t define any copy assignment operator then ____________________
Correct Answer is : Compiler gives an implicit definition
11. Declaring a copy constructor doesn’t suppresses the compiler generated copy assignment operator.
12. In copy constructor definition, if non const values are accepted only ________
Correct Answer is : Only non – const objects are accepted
13. How many objects can be assigned to a single address?
Correct Answer is : As many as required
14. Use of assignment operator ____________________
Correct Answer is : Changes its use, when used at declaration and in normal assignment
15. If more than one object refer to the same address, any changes made
Correct Answer is : From any object will be visible in all
16. How to make more than one object refer to the same object?
Correct Answer is : Initialize the object with another at declaration
17. We can assign ______________________
Correct Answer is : Value of one reference variable to another
18. Assigning reference to an object _________________
Correct Answer is : Will not create any other copy of the object
19. Which among the following is true?
Correct Answer is : We can use direct assignment to same class objects
20. Assigning objects takes place while passing the arguments.
Correct Answer is : FALSE