Unit 3
OOP Concepts
The core of OOP in Java: classes and objects, constructors and overloading, memory and garbage collection, modifiers, encapsulation, inheritance, polymorphism, abstraction, abstract classes and interfaces.
What you will learn
After this unit you can:
- Model real-world things as classes
- Declare attributes and methods
- Create objects and access members
- Write constructors and overloaded methods
- Explain destructors and object lifecycle
- Explain heap allocation and garbage collection
- Apply access and non-access modifiers
- Encapsulate data with getters and setters
- Build inheritance hierarchies and override methods
- Use polymorphism
- Apply abstraction with abstract classes and interfaces
- Give real-world examples of encapsulation and abstraction
Topics in this unit
3.1Classes and Objects✓3.1.1Classes and objects in the real world✓3.1.2Attributes and methods✓3.1.3Creating objects and accessing members✓3.1.4The this keyword and constructors✓3.1.5Destructors and releasing resources✓3.1.6Overloading✓3.1.7Static members and a complete program✓3.1.8Self-check and practice✓3.2Memory Management in OOP✓3.2.1Stack, heap and dynamic allocation✓3.2.2Garbage collection and the object lifecycle✓3.2.3Self-check and practice✓3.3Modifiers✓3.3.1Access modifiers✓3.3.2Non-access modifiers✓3.3.3Self-check and practice✓3.4Encapsulation✓3.4.1Getters, setters and validation✓3.4.2Self-check and practice✓3.5Inheritance✓3.5.1The extends and super keywords✓3.5.2Hierarchies and types of inheritance✓3.5.3Multiple inheritance and the diamond problem✓3.5.4Method overriding✓3.5.5Constructor order✓3.5.6Self-check and practice✓3.6Polymorphism✓3.6.1Compile-time and run-time polymorphism✓3.6.2Run-time polymorphism in action✓3.6.3Upcasting, downcasting and instanceof✓3.6.4Self-check and practice✓3.7Abstraction✓3.8Abstract Classes and Interfaces✓3.8.1Abstract classes✓3.8.2Interfaces✓3.8.3Abstract class or interface?✓3.8.4Self-check and practice✓3.9Real-World Examples of Encapsulation and Abstraction✓