OOP PRINCIPLES:
Encapsulation
DEFINE
Encapsulation is restricting direct access to make sure that “sensitive” data is hidden from users
Encapsulation
HOW TO ACHIEVE ENCAPSULATION
Note: These public getters and setters’ method will help us to access and update private instance variables
Getter vs Setter
GETTER
SETTER
Encapsulation
WHY DO WE NEED ENCAPSULATION
ADVANTAGES OF OOP PRINCIPLES
Inheritance
DEFINE
It is receiving or sharing class members (methods and instance variables) from one class (parent class) to another class (child classes) with the extends keyword.
Inheritance
HOW TO ACHIEVE INHERITANCE
WHAT CAN BE INHERITED?
-In the same package: public - protected - default
-Different packages: public - protected
NOTE: There is no way to inherit private class members because private class members can only be used in the same class
Inheritance
WHY DO WE USE INHERITANCE?
Method Overriding and Method Overloading
METHOD OVERRIDING
METHOD OVERLOADING
this keyword vs super keyword
- super keyword is a reference to a current parent object
this() vs super()
Constructor Chaining
DEFINE
It is invoking one custom constructor in another
Inheritance
ACCESS MODIFIERS
Can a class extend to multiple classes
- HOWEVER, one class can be parent to many other child classes
WHAT IS IS-A-RELATIONSHIP
WHAT IS HAS-A-RELATIONSHIP
WHAT IS IS-A-RELATIONSHIP?
-Inheritance
WHAT IS HAS-A-RELATIONSHIP?
Book - Author
Method overriding vs overloading
Abstraction
DEFINE
It is known as hiding the implementation and providing the functionality. Abstraction only makes sense when used with inheritance.
Abstraction
ABSTRACTION CLASS RULES
Abstraction
INTERFACES RULES
Abstraction
TYPES
2. interfaces
Abstraction Class and Interface
SIMILARITIES
Abstraction Class and Interface
DIFFERENCES
Polymorphism
DEFINE