1/20
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Object-Oriented Programming
What does OOP stands for?
Encapsulation
The principle of pushing data(fields) and methods that operate on that data into a single unit (class), while restricting direct access to the data by using access modifiers like private and exposing controlled access through public getter and setter methods. This ensures data hiding, security, and better maintainability.
Inheritance
An Object-Oriented Programming(OOP) concept where one class (child/subclass)acquires the properties and behaviors of another class(parent/superclass) using the extends keyword. This promotes code reusability, better organization, and allows polymorphism.
Polymorphism
In Java it means “many forms” — it allows the same method or object to behave differently depending on the context, typically through method overloading (compile-time polymorphism) and method overriding (runtime polymorphism). It’s one of the core principles of Object-Oriented Programming (OOP) that enables flexibility and code reuse.
Data Hiding
Class fields are declared private so they cannot be accessed directly from outside.
Controlled Access
Public methods (getters and setters) are provided to read or modify private fields.
Data Hiding and Controlled Access
Key points of Encapsulation
Benefits of Encapsulation
- Protects data integrity by controlling how values are set.
- Makes code easier to maintain and modify without breaking other parts.
- Improves readability and usability.
- Supports modular programming.
Customization and Polymorphism
Key points of Inheritance
Superclass (Parent/Base Class)
The class whose features are inherited.
Subclass (Child/Derived Class)
The class that inherits from the superclass.
Customization
Subclass can add new fields/methods or override existing ones.
Polymorphism
Enables writing flexible code where a parent reference can point to child objects.
Single, Multilevel, Hierarchical, and Hybrid
Types of Inheritance
Single Inheritance
One class inherits from another.
Multilevel Inheritance
A class inherits from a subclass (chain).
Hierarchical Inhertiance
Multiple classes inherit from one superclass.
Hybrid Inheritance
Combination of different types (not directly supported in Java due to ambiguity, but achievable via interfaces).
Compile-time (Method Overloading) and Runtime (Method Overriding)
Key points of Polymorphism
Compile-time Polymorphism (Method Overloading)
- Multiple methods with the same name but different parameter lists.
- Decided at compile time.
Runtime Polymorphism (Method Overriding)
- A subclass provides a specific implementation of a method already defined in its superclass.
- Decided at runtime based on the actual object type.