What is the difference between subclass and object? Is subclass also an object of the class? | Sololearn: Learn to code for FREE!
0

What is the difference between subclass and object? Is subclass also an object of the class?

Is all objects are the subclass of a superclass

6th Dec 2017, 6:12 AM
Nikhila Tammu
Nikhila Tammu - avatar
3 Réponses
+ 6
Object is an instance of a class. You can treat class definition as an instruction how the objects of this class are created, what variables and methods they hold and what they do. Subclasses inheriting from this class are simply modified instructions on how a slightly different type of objects are created. Themselves, subclasses are NOT instances of the superclass.
6th Dec 2017, 6:48 AM
Kuba SiekierzyŇĄski
Kuba SiekierzyŇĄski - avatar
0
Is subclass also does not hold any info?
6th Dec 2017, 6:38 AM
Nikhila Tammu
Nikhila Tammu - avatar
- 1
Classes do not hold any information, while an object does.
6th Dec 2017, 6:15 AM
Saurabh Suman
Saurabh Suman - avatar