Class-and-object
Question 1 |
Which of the following is a correct statement?
Composition is a strong type of association between two classes with full ownership. | |
Composition is a strong type of association between two classes with partial ownership. | |
Composition is a weak type of association between two classes with partial ownership. | |
Composition is a weak type of association between two classes with strong ownership. |
Question 1 Explanation:

Question 2 |
Which of the following is not a correct statement?
Every class containing abstract method must be declared abstract. | |
Abstract class can directly be initiated with ‘new’ operator. | |
Abstract class can be initiated. | |
Abstract class does not contain any de nition of implementation. |
Question 2 Explanation:
A class which is declared as abstract is known as an abstract class. It can have abstract and non-abstract methods. It needs to be extended and its method implemented. It cannot be instantiated.
Rules:
1. An abstract class must be declared with an abstract keyword.
2. It can have abstract and non-abstract methods.
3. It cannot be instantiated.
4. It can have constructors and static methods also.
5. It can have final methods which will force the subclass not to change the body of the method.
Rules:
1. An abstract class must be declared with an abstract keyword.
2. It can have abstract and non-abstract methods.
3. It cannot be instantiated.
4. It can have constructors and static methods also.
5. It can have final methods which will force the subclass not to change the body of the method.
Question 3 |
Which of the following C++ statements correctly declares an abstract class?
Class A {virtual void show() = 0; };
| |
Class A {void show() = 0;};
| |
Class A {void show() { } ; };
| |
Class A {show() = 0; }; |
Question 4 |
If a class C is derived from class B, which is derived from class A, all through public inheritance, then a class C member function can access
Protected and public data only in C and B | |
Protected and public data only in C | |
Private data in A and B | |
Protected data in A and B |
Question 4 Explanation:
The following table shows the access to members permitted by each modifier.

Question 5 |
Members of class by default are
Public | |
Private | |
Protected | |
Mandatory to specify |
Question 5 Explanation:
→A class in C++ is a user defined type or data structure declared with keyword class that has data and functions (also called methods) as its members whose access is governed by the three access specifiers private, protected or public (by default access to members of a class is private).
→The private members are not accessible outside the class; they can be accessed only through methods of the class. The public members form an interface to the class and are accessible outside the class.
→The private members are not accessible outside the class; they can be accessed only through methods of the class. The public members form an interface to the class and are accessible outside the class.