ICSE Class 10 Computer Applications Question 9 of 19

Constructors — Question 9

Back to all questions
9
Question

Question 9

What condition(s) a function must specify in order to create objects of a class ?

Answer

Every time an object is created, the constructor is automatically invoked. If the function creating the object, does not have access privilege for the constructor, it cannot be invoked for that function. Thus, the object cannot be created by such function.

Therefore, it is essential for a function to have access privilege for the constructor in order to create objects of a class.