B02D-2016 – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Exam Questions-CBSE12A-2016-B02D #PYTHON#6294    siteicon   siteicon  

Problem Statement - B02D-2016

How do we implement abstract method in python? Give an example for the same.

Solution

TC++ #6294

Abstract method: An unimplemented method is called an abstract method. When an abstract method is declared in a base class, the derived class has to either define the method or raise “NotImplementedError”
OR
Abstract Method can be used to enable parent class method execution.

class Shape(object):
    def findArea(self):
        pass
class Square(Shape):
    def __init__(self,side):
        self.side = side
    def findArea(self):
        return self.side * self.side


Share

CSKC| Created: 11-Jan-2019 | Updated: 11-Jan-2019|CBSE12A-2016









Back