Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes, there is a distinction in the type of object declaration when instantiating a subclass or superclass. When instantiating a subclass, the object is declared with the subclass type, whereas when instantiating a superclass, the object is declared with the superclass type. This is because a subclass is a specialization of the superclass, so it has additional properties and methods that are not present in the superclass. By declaring the object with the subclass type, you can access these additional properties and methods. On the other hand, declaring the object with the superclass type allows you to treat objects of different subclasses as if they were all of the same type, which can be useful in certain situations.