Abstract class and Absteract Method in python

technical talkiess
0

 Abstract class and Absteract Method:- 


# abstract class banana ne ke liye ye wali module or decoraterss ko import karna padta hai

from abc import ABC,abstractmethod


class test1(ABC):

    # printdetails abhi abstract ho gaye hai hai jo bhi class isko inherit karenga usko ye wai method ko apne function me define karna hi padenga nahi to error show hoga

    @abstractmethod

    def printDetails():

        return 0


class test2(test1):

    def __init__(self):

        self.width = 3

        self.height = 4


    def printDetails(self):

        return self.height * self.width



vishal = test2()

print(vishal.printDetails())

# aap direct abstract class ka objecc nahi bana sakte hai error denga

test44 = test1()
Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)