Table of Contents
Object Oriented Programming in Java simple guide with examples for beginners is what I am sharing today, based on what I studied and wrote down in my notes. When I first started programming, I worked with Procedure-Oriented Programming (POP), where everything was written step by step. But as I learned more, I realized how Object Oriented Programming (OOP) is different and much more powerful. In this post, I will explain the difference between POP and OOP, share examples like Nancy and Rahul, and go over concepts such as classes, objects, encapsulation, inheritance, and polymorphism.
When I first started learning programming, I was introduced to a way of coding called Procedure-Oriented Programming (POP). In this style, everything is written as a sequence of steps or procedures. It works fine for small programs, but as the project grows, it becomes difficult to manage. Today, I spent time learning about Object Oriented Programming (OOP) in Java, and I realized it is a completely different mindset compared to POP. Instead of thinking only about functions and procedures, OOP encourages us to think in terms of objects—real-world entities with properties and behaviors.
POP vs OOP: The Difference
A strong understanding of POP vs OOP is necessary for anyone following an Object Oriented Programming in Java simple guide with examples for beginners.
- In Procedure-Oriented Programming, the program is divided into functions. Each function performs a task, and data is passed between functions. The focus is on how the task is done. A good example is the C programming language.
- In Object Oriented Programming, the program is divided into objects. Each object represents something real, like a student, car, or bank account. The focus is on what the object is and how it interacts with other objects. Java is a strong example of an OOP language.
Think of it like this: POP is similar to writing a cooking recipe step by step, while OOP is like having different chefs (objects), each with their own specialty. You simply ask the chef to cook, and they already know how to do it.
Classes and Objects Explained
One of the first things I learned in OOP is the concept of classes and objects.
- A class is like a blueprint or template. It defines the attributes (variables) and behaviors (methods) of something.
- An object is a real instance created from a class. It uses the blueprint to come alive in the program.
The Nancy and Rahul student example is one of the simplest ways to introduce beginners to classes and objects in Java. By including such practical code in this Object Oriented Programming in Java, I was able to connect theory with actual implementation
class Student {
String name;
int age;
void study() {
System.out.println(name + " is studying.");
}
}
public class Main {
public static void main(String[] args) {
Student nancy = new Student();
nancy.name = "Nancy";
nancy.age = 20;
nancy.study();
Student rahul = new Student();
rahul.name = "Rahul";
rahul.age = 22;
rahul.study();
}
}
When you run this program, the output will be:
Nancy is studying.
Rahul is studying.
Here, Student
is the class, and nancy
and rahul
are the objects created from it. Each object has its own values for name and age, but both share the same structure defined in the class.
The Four Main OOP Concepts
As I explored further, I learned about the four pillars of Object Oriented Programming: Encapsulation, Inheritance, Polymorphism, and Abstraction.
1. Encapsulation
Encapsulation is about bundling the data and the methods that operate on that data into a single unit. It also means restricting direct access to some details. For example, in a BankAccount
class, the balance should not be directly accessible to anyone. Instead, you allow access through methods like deposit()
and withdraw()
. This protects the data from being changed accidentally.
2. Inheritance
Inheritance allows one class to reuse the properties and methods of another class. For example, a Car
class can inherit from a Vehicle
class. The Car
automatically has features of Vehicle
such as wheels or engine capacity but can also have its own unique features like air conditioning or music system. This avoids repeating code and makes it easy to build complex systems.
3. Polymorphism
Polymorphism means “many forms.” In programming, it allows the same method name to behave differently depending on the object calling it. For instance, imagine a draw()
method. If the object is a Circle
, draw()
will draw a circle. If the object is a Rectangle
, draw()
will draw a rectangle. This makes code flexible and reusable.
4. Abstraction
Abstraction is about hiding the unnecessary details and only showing the essential features. A good real-world example is driving a car. As drivers, we only interact with the steering wheel, accelerator, and brakes. We do not see how the engine or transmission system works internally. In Java, abstraction can be achieved using abstract classes and interfaces.

Why OOP Matters
“In preparing this Object Oriented Programming in Java I realized the biggest strength of OOP lies in reusability, scalability, and easier maintenance
- Reusability: Once you create a class, you can reuse it in different parts of the program or even in other projects.
- Maintainability: Since the code is divided into objects, it is easier to locate and fix errors.
- Scalability: Large systems can be built by combining multiple classes and objects without making the program messy.
- Real-world modeling: OOP maps closely to real-life entities, which makes designing systems more intuitive.
My Takeaway
Today’s learning session on Object Oriented Programming in Java has given me a fresh perspective on coding. I started by comparing POP and OOP, and then I dived into classes, objects, and the four key principles of OOP. The Nancy and Rahul student example helped me visualize how classes and objects actually work in practice.
For me, the biggest realization is that OOP is not just a set of rules but a way of thinking. Instead of writing endless lines of functions, I now think in terms of entities, their properties, and their relationships. I know this is just the beginning, but concepts like encapsulation, inheritance, polymorphism, and abstraction are already making programming feel more structured and powerful.
My Handwritten Notes
While working on this Object Oriented Programming in Java simple guide with examples for beginners, I made handwritten notes to capture the basics in my own words. So while learning, I prepared handwritten notes. Here’s a copy of them in case it helps anyone else who is starting out:
Download My Notes PDF
Further Reading
While studying, I also explored some external resources that explain OOP concepts in depth. If you want to learn further, I recommend:
Oracle Official Java OOP Concepts
GeeksforGeeks – OOP Concepts in Java
You May Also Like
If you’re enjoying this beginner-friendly Java series, here are a few of my other helpful posts that you might find useful:
- Java Introduction to Programming: My Exciting Day 1 Journey from Zero to Beginner
My personal first-day experience learning Java — from setting up the environment to writing my very first program. - Java Learning Roadmap 2025 – From Zero to Hero
A step-by-step guide to how I plan to learn Java in 2025, perfect for beginners like me. - Aptitude Tricks for Beginners – Easy Mental Math Techniques
Quick tricks for multiplication, LCM, squaring, and cubes — useful for placement and coding exams. - Types of Nouns in English Grammar – Simple Explanation with Examples
Learn all types of nouns clearly with examples — great for communication skills and competitive exams. - Data Cleaning with Titanic Dataset – A Beginner’s Guide
Learn the complete, beginner-friendly process of cleaning and preparing the Titanic dataset for machine learning, with practical examples and tips. - History Of Java Programming Language
By writing about Object Oriented Programming in Java, I not only organized my own learning but also hope to make it easier for beginners to follow.”