Issue
I am currently learning Python, moved from the basics to Object Oriented Programming implementation. For instance, in the code snippet below (I've written it from the top of my head, sorry if it looks, amateur)
class A_subclass(The_superclass):
pass
I wanted to clearly understand the attributes/methods that are available by heritage to subclasses. If we use the code example above. A_subclass has inherited all the attributes & methods from The_superclass. Are there any exemptions? or the sub-class A_subclass has everything that the parent class The_superclass has?
Solution
A subclass “inherits” all the attributes (methods, etc) of the parent class. This means that a subclass will have everything that its “parents” have. You can then change (“override”) some or all of the attributes to change the behavior. You can also add new attributes to extend the behavior.
Thus. All attributes & methods are available by heritage to subclasses.
Answered By - Kevin Njuguna Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.