Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Polymorphism | Polymorphism
Object-Oriented Programming in Python

bookPolymorphism

Polymorphism is a class property to modify superclass functionality. Methods or attributes can have various meanings and purposes inside the different classes. Methods in the superclass are virtual, that means they can be overridden in the children's classes.

Code

Each class has the say method. But each method performs different things.

123456789101112131415161718
class Bird: def say(self): print('Chirp') class Duck(Bird): def say(self): print('Quack') class Rooster(Bird): def say(self): print('Cock-a-doodle-do') bird = Bird() bird.say() duck = Duck() duck.say() rooster = Rooster() rooster.say()
copy

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 4. Kapitel 1

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Suggested prompts:

Fragen Sie mich Fragen zu diesem Thema

Zusammenfassen Sie dieses Kapitel

Zeige reale Beispiele

Awesome!

Completion rate improved to 7.69

bookPolymorphism

Swipe um das Menü anzuzeigen

Polymorphism is a class property to modify superclass functionality. Methods or attributes can have various meanings and purposes inside the different classes. Methods in the superclass are virtual, that means they can be overridden in the children's classes.

Code

Each class has the say method. But each method performs different things.

123456789101112131415161718
class Bird: def say(self): print('Chirp') class Duck(Bird): def say(self): print('Quack') class Rooster(Bird): def say(self): print('Cock-a-doodle-do') bird = Bird() bird.say() duck = Duck() duck.say() rooster = Rooster() rooster.say()
copy

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 4. Kapitel 1
some-alt