ICSE Class 9 Computer Applications Question 7 of 10

Elementary Concepts of Objects and Classes — Question 7

Back to all questions
7
Question

Question 7

Give the reason why a class is known as:

i. An object factory

Answer

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.