English

Explain the concept of overriding methods.

Advertisements
Advertisements

Question

Explain the concept of overriding methods.

Code Writing
Explain
Advertisements

Solution

Method overriding happens when a derived class defines a method with the same name as a method in its base class. The derived-class version is called when the method is invoked using a derived-class object.

class Person(object):
    def show(self):
        print("Person")

class Student(Person):
    def show(self):
        print("Student")
 
shaalaa.com
  Is there an error in this question or solution?
Chapter 4: Inheritance - EXERCISE [Page 78]

APPEARS IN

CBSE Computer Science with Python [English] Class 12
Chapter 4 Inheritance
EXERCISE | Q 11. | Page 78
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×