18. Give the reason why a class is known as:
ci An object factory
ii. A composite data type
iii. A user-defined data type
Answers
Answer:
because it is set of information...
Answer:
The reason why a class is known as are:
i) The term factory typically is used for holding similar kind of objects within it. Generally, an object is created by using information available in the class. It also contains details of an object's internal data and when an object is brought into existence, it is called instantiation.
Thus, we can conclude that class is a prototype of an object. Each object belonging to a specific class possesses the data and the methods defined within the class.
It produces objects of similar type. Hence, it is termed as object factory.
ii) Class is a prototype of an object which contains all fundamental data types like byte, short, int, long, float, double, char and boolean.
Any data type that is based on primitive data types are known as composite data type. Since class uses these data types to perform various tasks, so class is also known as composite data type.
iii) Java language uses some pre-defined data types such as int, float and char.
These data types are also known as composite data type, which provide some preliminary facilities in Java programming. Similarly, a user may create a data type and declare certain characteristics and behaviour within it. This can be done by using a class.
This is the reason why a class is referred as user defined data type.