Table of contents
No headings in the article.
Classes:
Definition: A class is a blueprint or template that defines the properties (attributes) and behaviours (methods) of objects.
Purpose: Classes provide a way to organize and structure code by encapsulating data and functions related to a specific concept or entity.
Objects:
Definition: Objects are instances of a class that represent real-world entities and have their own unique state and behaviour.
Purpose: Objects allow us to create multiple instances of a class, each with its own set of data and behaviour.
Inheritance:
Definition: Inheritance is a mechanism in object-oriented programming that allows a class to inherit properties and methods from another class.
Purpose: Inheritance promotes code reuse, facilitates the creation of hierarchical relationships between classes, and supports the concept of specialization.
a. Base Class/Parent Class/Superclass: The class from which properties and methods are inherited.
b. Derived Class/Child Class/Subclass: The class that inherits properties and methods from the base class.
c. Single Inheritance: When a subclass inherits from a single base class.
d. Multiple Inheritance: When a subclass inherits from multiple base classes.
e. Hierarchical Inheritance: When multiple subclasses inherit from a single base class. f. Multi-level Inheritance: When a subclass becomes the base class for another subclass.
Polymorphism:
Definition: Polymorphism refers to the ability of objects of different classes to respond to the same message or method invocation.
Purpose: Polymorphism allows for code flexibility, extensibility, and the implementation of different behaviours for different object types.
Method Overriding:
Definition: Method overriding is a feature of inheritance where a subclass provides its own implementation of a method defined in the base class.
Purpose: Method overriding allows for the modification or extension of the behaviour of inherited methods in the context of the subclass.
a. Overridden Method: The method in the base class that is redefined in the subclass.
b. Overriding Method: The method in the subclass that provides a new implementation for the overridden method.