Python Programming - Classes - Discussion
Discussion Forum : Classes - General Questions (Q.No. 27)
27.
Consider the following Python code:
class Employee:
def __init__(self, name, salary):
self.name = name
self.salary = salary
def display_info(self):
return f"{self.name} earns {self.salary} per month."
class Manager(Employee):
def __init__(self, name, salary, team_size):
super().__init__(name, salary)
self.team_size = team_size
Which object-oriented principle is applied in this code?
Answer: Option
Explanation:
The code demonstrates the concept of inheritance, where the `Manager` class inherits from the `Employee` class, inheriting its attributes and methods.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers