Introduction To OOP
Introduction To OOP
Programming
Part 1: Understanding OOP
Concepts and Principles
Prepared for Beginning Java Students
OOP works the same way! Instead of writing one massive program with
all code mixed together, we organize related data and functions into objects.
1
Real-World Example: A Car
A car has:
In OOP, we would create a ”Car” object that contains all these prop-
erties and behaviors together!
2.1 1. Encapsulation
What is Encapsulation?
Encapsulation is the bundling of data and methods within a single
unit (class), while hiding the internal details from the outside world.
• You don’t need to know HOW the remote sends signals to the TV
2
• Users of our class don’t need to know HOW things work internally
Benefits of Encapsulation
1. Data Protection: Internal data can’t be accidentally changed
2.2 2. Abstraction
What is Abstraction?
Abstraction means showing only essential features and hiding unnec-
essary implementation details from the user.
3
Example
When you use a microwave:
• Abstraction: You see buttons for time and power level (simpli-
fied interface)
2.3 3. Inheritance
What is Inheritance?
Inheritance allows a class (child/subclass) to inherit properties and
methods from another class (parent/superclass).
• You don’t start from zero - you build upon what already exists
Dog Cat
4
Benefits of Inheritance
1. Code Reusability: Don’t repeat common code
2.4 4. Polymorphism
What is Polymorphism?
Polymorphism means ”many forms.” It allows objects of different
types to be treated as objects of a common base type.
5
Same action name, different implementations!
Types of Polymorphism
1. Method Overloading: Multiple methods with same name but
different parameters
1. Encapsulation:
2. Abstraction:
3. Inheritance:
4. Polymorphism:
6
4 Why Learn OOP?
Benefits of OOP
1. Modularity: Code is organized into discrete objects
5 Common Misconceptions
Things Students Often Get Wrong
1. ”OOP is just about classes”
6 Summary
Object-Oriented Programming is a way of organizing code that mirrors how
we think about the real world:
• Encapsulation: Package data and methods together, hide internal
details
7
• Abstraction: Show only what’s necessary, hide complexity
7 What’s Next?
In the next document, we’ll learn:
Remember: These concepts might feel abstract now, but they’ll become
clearer when we start writing actual Java code!