B02D-2016D – Computer Sir Ki Class

Login


Lost your password?

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

Login
[lwa]



Exam Questions-CBSE12D-2016-B02D #PYTHON#6472    siteicon   siteicon  

Problem Statement - B02D-2016D

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

Solution

TC++ #6472

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”

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: 12-Jan-2019 | Updated: 12-Jan-2019|CBSE12D-2016









Back