Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help on these C plus plus Q. What does composition mean? That a class contains a

ID: 3917535 • Letter: H

Question

Help on these C plus plus

Q. What does composition mean?

That a class contains an attribute that references an object rather than a primitive type.

That a subclass extends a superclass.

That a superclass pointer is pointing to a subclass object.

That attributes should be declared private.

_____________________________________

Q. Which of the following statements is FALSE?

"class A : public B" means B is a subclass of A

A subclass is usually extended to contain more functions and more detailed information than its superclass.

"class A : public B" means A is a subclass of B

A subclass object can be used in any place a superclass object is expected.

_______________________________________

Q. Which of the following statements is FALSE?

If a function overloads another function , these two functions must have the same signature.

A subclass can overload a function of its parent class

If a function overrides another function , these two functions must have the same signature.

A function can be overloaded in the same class.

_________________________________________

Q.Object-oriented programming allows you to derive new classes from existing classes. This is called ____.

encapsulation

composition

abstraction

inheritance

__________________________________________

Q. Polymorphism is based on the fact that ____.

A class can contain objects of other classes.

A class can extend another class.

Attributes are usually private.

A superclass pointer can point to a subclass object.

______________________________________

Q. What is the most suitable relationship between Employee and Faculty?

Composition

Aggregation

There is no relationship between these classes.

Inheritance

_______________________________________

Q. Which of the following statements is true?

A subclass is usually extended to contain more functions and more detailed information than its superclass.

"class A : public B" means that class B is a subclass of A

A subclass is a class whose object is in a composition relationship with another class.

A subclass is a subset of a superclass.

____

Explanation / Answer

Q. What does composition mean?

That a class contains an attribute that references an object rather than a primitive type.

That a subclass extends a superclass.

That a superclass pointer is pointing to a subclass object.

That attributes should be declared private.

Ans: That a class contains an attribute that references an object rather than a primitive type.
_____________________________________

Q. Which of the following statements is FALSE?

"class A : public B" means B is a subclass of A

A subclass is usually extended to contain more functions and more detailed information than its superclass.

"class A : public B" means A is a subclass of B

A subclass object can be used in any place a superclass object is expected.

Ans: "class A : public B" means B is a subclass of A
Here B is superclass and A is subclass of B.

_______________________________________

Q. Which of the following statements is FALSE?

If a function overloads another function , these two functions must have the same signature.

A subclass can overload a function of its parent class

If a function overrides another function , these two functions must have the same signature.

A function can be overloaded in the same class.

Ans: If a function overloads another function, these two functions must have the same signature.
For overloading functions should have differnent signatutres.

_________________________________________

Q.Object-oriented programming allows you to derive new classes from existing classes. This is called ____.

encapsulation

composition

abstraction

inheritance

Ans:inheritance
inheritance is a feature that allow to derive new class from existing class. new class is known as derived class and existing class is called base class.
__________________________________________

Q. Polymorphism is based on the fact that ____.

A class can contain objects of other classes.

A class can extend another class.

Attributes are usually private.

A superclass pointer can point to a subclass object.


Ans: A superclass pointer can point to a subclass object.

it happens in case of runtime polymorphism.

______________________________________

Q. What is the most suitable relationship between Employee and Faculty?

Composition

Aggregation

There is no relationship between these classes.

Inheritance


Ans: Inheritance
Faculty will act as subclass for Employee class.
_______________________________________

Q. Which of the following statements is true?

A subclass is usually extended to contain more functions and more detailed information than its superclass.

"class A : public B" means that class B is a subclass of A

A subclass is a class whose object is in a composition relationship with another class.

A subclass is a subset of a superclass.

Ans:A subclass is usually extended to contain more functions and more detailed information than its superclass.