Test Series - cpp

Test Number 80/102

Q: What happens when only one argument is supplied to flip() function?
A. All bits are flipped in a bitset
B. Bit corresponding to argument bit is flipped
C. All alternate bits are flipped in a bitset
D. First bit is flipped
Solution: When only one argument is supplied to flip() function then bit corresponding to that index only is flipped.
Q: Which operator is used as not operator in bitset?
A. |
B. &
C. ~
D. ^
Solution: ~ operator is used as not operator i.e. the negation of a bit for bitset variables in C++.
Q: Which operator is used to take AND of two bitset variables?
A. ~
B. &
C. |
D. ^
Solution: & operator is used as AND operator for bitset variables in C++. ANDing of two bits are 1 only if both are 1.
Q: What is the class relationship?
A. A relationship between classes that tells how they are related
B. A relationship between classes that tells how much power one class has over other class
C. A relationship between classes that tells which parts of a class is visible to other classes
D. All of the mentioned
Solution: The Class relationship is a concept that helps us in differentiating how one class is related to other classes, the power of one over other and which part one class can be accessed by other class.
Q: How many types of class relationships are there?
A. 1
B. 2
C. 3
D. 4
Solution: There are basically four types of class relationships namely Inheritance, Aggregation, Composition and Association relationships between classes.
Q: Which type of relationship is modelled by Inheritance?
A. Is-A relationship
B. Has-A relationship
C. Part-Of relationship
D. Belongs-to relationship
Solution: Inheritance models Is-A type of relationship between classes. This is because in this case derived class inherits all property of the base class and Is-A type of B class.
Q: How the relationship is made in Association?
A. Through the objects of classes
B. Through constructor
C. Through destructor
D. Through class Names
Solution: Association relationship between classes is made using the objects of classes like we have a bank object denoting ABC bank and some objects of Employee class XYZ1, XYZ2 and so on. So, in this case, XYZ1 is an employee in ABC bank so there is a relationship between these two objects.
Q: How many types of Association can be there between classes?
A. 1
B. 2
C. 3
D. 4
Solution: There can be four types of an association relationship between classes namely one-to-one, one-to-many, many-to-one and many-to-many.
Q: Why do we need relationships between classes?
A. To use the functionality of one class into other
B. To enhance the communication between classes
C. To increase code re-usability
D. All of the mentioned
Solution: Relationships are needed to increase the use of features of one class into the other classes i.e. increasing the re-usability of codes and increasing communication between classes.
Q: Composition is also a type of _______________ relationship.
A. Aggregation
B. Association
C. Inheritance
D. Both Aggregation an Association
Solution: Composition is also a type of Both Aggregation and Association relationship. Composition relationships are string relationships whereas others are a superset of this relationship.
Q: Which type of relationship is modelled by Composition?
A. Is-A relationship
B. Has-A relationship
C. Part-Of relationship
D. Have-A relationship
Solution: Composition models the part-of relationship between classes. In this children cannot exits without a parent, therefore, they are part of each other.
Q: Which type of relationship is modelled by Aggregation?
A. Is-A relationship
B. Has-A relationship
C. Part-Of relationship
D. Have-A relationship
Solution: Aggregation models the has-a relationship between classes. In this children can exist without a parent, therefore, they have a relationship.
Q: Which of the following relationships is uni-directional?
A. Aggregation
B. Association
C. Composition
D. Both Aggregation and Composition
Solution: Both Association and composition are uni-directional relationships. For example, departments can have students but another way around is not possible.

You Have Score    /13