What are the basic features of inheritance?
(i) Characters are controlled by genes.(ii) Each gene controls one character.(iii) There may be two or more forms of the gene.(iv) One form may be dominant over the other.(v) Genes are present on chromosomes.(vi) An individual has two forms of the gene whether similar or dissimilar.(vii) The two forms separate at the time of gamete formation.(viii) The two forms are brought together in the zygote.
What are the basic features of inheritance?
Basic Features of Inheritance
Inheritance is a fundamental concept in object-oriented programming (OOP) that allows classes to inherit properties and behaviors from other classes. It promotes code reusability and enables the creation of more organized and modular code structures. The basic features of inheritance include:
1. Code Reusability:
Inheritance allows us to reuse the existing code from a parent class in a child class. The child class inherits the attributes and methods of the parent class, eliminating the need to rewrite or duplicate code. This saves time and effort in development and maintenance.
2. Single Inheritance:
In single inheritance, a class can inherit properties and behaviors from only one parent class. The child class extends the functionality of the parent class by inheriting its characteristics. The parent class is also called the superclass or base class, while the child class is known as the subclass or derived class.
3. Multilevel Inheritance:
Multilevel inheritance allows a class to inherit properties and behaviors not only from its immediate parent class but also from its ancestor classes. This creates a hierarchical relationship between classes, forming a chain of inheritance. Each class inherits the features of its parent class, and the process continues until the topmost class is reached.
4. Hierarchical Inheritance:
Hierarchical inheritance involves multiple subclasses inheriting properties and behaviors from a single superclass. This means that a single parent class can have multiple child classes. Each child class inherits the common attributes and methods of the parent class while adding its own unique features.
5. Method Overriding:
Inheritance allows subclasses to override methods defined in the parent class. Method overriding enables a child class to provide its own implementation of a method inherited from the parent class. This allows for customization and specialization of behavior in the child class while still maintaining the basic structure inherited from the parent class.
6. Access Modifiers:
Inheritance respects the access modifiers (public, private, protected) defined in the parent class. Public members are accessible in both the parent and child classes, protected members can be accessed within the same package or subclasses, and private members are only accessible within the parent class. Inheritance thus maintains encapsulation and data hiding.
7. Polymorphism:
Inheritance is closely related to polymorphism, which allows objects of different classes to be treated as objects of a common superclass. This means that a variable of the superclass type can refer to objects of its subclasses. This concept enables flexibility and extensibility in programming, as different objects can be used interchangeably through a common interface.
Overall, inheritance is a powerful feature of object-oriented programming that provides code reuse, extensibility, and flexibility. By inheriting properties and behaviors from existing classes, new classes can be created with enhanced functionality while maintaining a structured and modular codebase.
To make sure you are not studying endlessly, EduRev has designed Class 10 study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Class 10.