EBK STARTING OUT WITH PYTHON
EBK STARTING OUT WITH PYTHON
4th Edition
ISBN: 8220106714294
Author: 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
what is Method ?
Clarify what overriding a method entails and how it differs from overloading.
Explain Method Overloading/Overriding and give examples regarding them.