Object Oriented Programming Concepts — Question 18
Back to all questionsQuestion 18
Give the reason why a class is known as:
i. An object factory
A class is called an object factory because objects are created from the class that contains common attributes and behaviour. The class behaves like a specification for creating such similar objects.
ii. A composite data type
A class is composed of member variables which are of different data types. Hence, a class can be viewed as a composite data type.
iii. A user-defined data type
The entire data and the code, contained in an object, becomes a user-defined data type using the concept of a class. The class may be considered as a data type and an object as a variable of that data type. For example, once the Bird class has been defined, the statement
Bird parrot;
will create a parrot object belonging to the Bird class.