Subsets vs Inheritance
A set is a collection of things. A set can be a collection of numbers, colors, socks, or anything. B is a subset of C if all the elements of B are contained in C. For example, the set of prime numbers is a subset of the set of integers. The set of all sweatpants is a subset of the set of all gym clothes.
You are already familiar with classes and inheritance. B extends C, or B inherits from C, when every object of B is-a kind of C. For example, the class Manager extends Employee, and Film extends Production.
a. In what ways are the notions of sets and classes the same?
b. In what ways are the notions of sets and classes different?
c. Give an example of two classes A and B, where B naturally extends A, and B is a subset of A.
d. Give an example of two classes A and B, where B is a subset of A, but B does notnaturally extend A.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.