PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, October 26, 2022

[FIXED] Which attributes or methods are available by heritage to subclasses?

 October 26, 2022     oop, python, python-3.x     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing