Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
Expert Solution & Answer
Book Icon
Chapter 11, Problem 3SA

Explanation of Solution

Polymorphism:

In Python, one of the features of object-oriented concept is “polymorphism” and it refers an object’s capability to take different forms.

  • • It allows the subclass that may contain methods having same name as the method in its superclass.
  • • A program can call the correct method using the type of an object that may use to call it.

Method overridden:

In Python, if a subclass contains a method having the same name as the method in its superclass, then it is referred as “method overridden”.

Example:

Consider the following example for method over-riding:

#Base class "Student"

class Student(object):

         # class constructor

         def __init__(self, s_name):

              #Initialize student name

              self.s_name = s_name

         # To get student name

         def getname(self):

              #Return student name

              return self...

Blurred answer
Students have asked these similar questions
Clarify what overriding a method entails and how it differs from overloading.
Explain method overloading and provide an example.
What is method overriding?
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education