OOPS – Fundamentals, Models, Relations and Principles

Java 14 min min read Updated: Mar 31, 2026 Beginner
OOPS – Fundamentals, Models, Relations and Principles
Beginner Topic 20 of 25

OOPS – Fundamentals, Models, Relations and Principles

Object-Oriented Programming System, commonly called OOPS, is one of the most important programming paradigms in Java. Java is strongly object-oriented in design, and almost every real-world Java application is built using OOPS concepts.

OOPS helps developers design software by modeling real-world entities as objects. Instead of focusing only on functions and procedures, object-oriented programming organizes software around data and the behavior associated with that data.

Key Concept: OOPS is a programming approach that organizes software using classes, objects, relationships, and design principles such as encapsulation, inheritance, polymorphism, and abstraction.

What is OOPS?

OOPS stands for Object-Oriented Programming System. It is a programming methodology in which a program is designed using objects and classes instead of only writing instructions step by step.

In OOPS:

  • data is grouped with related behavior
  • real-world entities are represented as objects
  • code is organized into reusable components
  • software becomes modular, scalable, and maintainable

Why OOPS is Important

OOPS is important because modern software systems are complex. Without a proper design model, code becomes difficult to manage, test, and extend.

  • improves code reusability
  • helps in modular development
  • reduces redundancy
  • makes maintenance easier
  • supports real-world software modeling

Real-World Understanding of OOPS

Consider a real-world example of a Student.

  • Properties → name, roll number, age
  • Behaviors → study(), attendClass(), takeExam()

In Java:

  • properties are represented using variables
  • behaviors are represented using methods
  • the entire structure is represented using a class

Basic OOPS Example

java class Student { String name; int age; void study() { System.out.println(name + " is studying"); } } public class Main { public static void main(String[] args) { Student s1 = new Student(); s1.name = "Amit"; s1.age = 20; s1.study(); } }

In this example:

  • Student is a class
  • s1 is an object
  • name and age are properties
  • study() is behavior

Fundamental Concepts of OOPS

The main fundamentals of OOPS are:

  • Class
  • Object
  • Encapsulation
  • Inheritance
  • Polymorphism
  • Abstraction

1. Class

A class is a blueprint or template used to create objects. It defines what data the object will have and what actions it can perform.

Example

java class Car { String color; String brand; void start() { System.out.println("Car started"); } }

2. Object

An object is a real instance of a class. It occupies memory and can use the data and behavior defined by the class.

Example

java Car c1 = new Car(); c1.color = "Red"; c1.brand = "Toyota"; c1.start();

3. Encapsulation

Encapsulation means wrapping data and methods into a single unit and controlling direct access to data.

This is usually achieved using private variables and public getter-setter methods.

Example

java class Account { private double balance; public void setBalance(double balance) { this.balance = balance; } public double getBalance() { return balance; } }

Here, direct access to balance is restricted.

4. Inheritance

Inheritance allows one class to acquire the properties and methods of another class.

It supports code reuse and hierarchy building.

Example

java class Animal { void eat() { System.out.println("Animal eats"); } } class Dog extends Animal { void bark() { System.out.println("Dog barks"); } }

Dog inherits from Animal.

5. Polymorphism

Polymorphism means “many forms.” It allows the same method or interface to behave differently in different situations.

Java supports:

  • compile-time polymorphism (method overloading)
  • runtime polymorphism (method overriding)

Method Overloading Example

java class MathUtil { int add(int a, int b) { return a + b; } int add(int a, int b, int c) { return a + b + c; } }

Method Overriding Example

java class Animal { void sound() { System.out.println("Animal sound"); } } class Dog extends Animal { void sound() { System.out.println("Dog barks"); } }

6. Abstraction

Abstraction means hiding implementation details and showing only the essential features to the user.

In Java, abstraction is mainly achieved through:

  • abstract classes
  • interfaces

Example

java abstract class Vehicle { abstract void start(); } class Car extends Vehicle { void start() { System.out.println("Car starts with key"); } }

OOPS Models

OOPS models are conceptual ways of representing software design using classes and objects.

Important modeling ideas include:

  • Object model
  • Class model
  • Interaction model
  • Relationship model

1. Object Model

The object model focuses on real-world entities as objects with state and behavior.

Example:

  • Object: BankAccount
  • State: accountNumber, balance
  • Behavior: deposit(), withdraw()

2. Class Model

The class model focuses on the structure of software using classes and their members.

Example:

  • Class: Employee
  • Variables: name, id, salary
  • Methods: work(), display()

3. Interaction Model

This model explains how objects communicate with each other through method calls.

Example:

  • Customer object calls Account object
  • Order object interacts with Product object

4. Relationship Model

OOPS uses relationships between classes to model real-world associations.

Important relations are:

  • IS-A relationship
  • HAS-A relationship
  • Association
  • Aggregation
  • Composition

OOPS Relations

1. IS-A Relationship

IS-A relationship represents inheritance.

Example:

  • Dog IS-A Animal
  • Car IS-A Vehicle
java class Animal { } class Dog extends Animal { }

2. HAS-A Relationship

HAS-A relationship means one class contains another class as a member. It is also called composition or aggregation depending on strength of ownership.

Example:

  • Car HAS-A Engine
  • Student HAS-A Address
java class Engine { } class Car { Engine engine = new Engine(); }

3. Association

Association means two classes are connected in some way and can interact with each other.

Example:

  • Teacher teaches Student
  • Customer places Order

4. Aggregation

Aggregation is a weak HAS-A relationship. The contained object can exist independently.

Example:

  • Department has Teachers
  • Library has Books

Even if the department is removed, teachers may still exist.

5. Composition

Composition is a strong HAS-A relationship. The contained object depends fully on the container object.

Example:

  • House has Rooms
  • Human has Heart

If the container is destroyed, the contained object logically does not exist in that context.

OOPS Principles

OOPS principles are the design rules that make object-oriented software strong and maintainable.

The four core principles are:

  • Encapsulation
  • Inheritance
  • Polymorphism
  • Abstraction

But in practical software engineering, OOPS also encourages:

  • modularity
  • reusability
  • extensibility
  • maintainability

Encapsulation Principle

Data should be protected inside the class and exposed only through controlled methods.

This improves security and data hiding.

Inheritance Principle

Common features should be placed in a parent class so child classes can reuse them.

Polymorphism Principle

The same method name or interface should support multiple behaviors depending on context.

Abstraction Principle

Only the essential view should be exposed to the outside world while internal complexity remains hidden.

Real-World Example Combining OOPS Fundamentals

java abstract class Person { String name; Person(String name) { this.name = name; } abstract void role(); } class Student extends Person { Student(String name) { super(name); } void role() { System.out.println(name + " is a student"); } } class Teacher extends Person { Teacher(String name) { super(name); } void role() { System.out.println(name + " is a teacher"); } } public class Main { public static void main(String[] args) { Person p1 = new Student("Amit"); Person p2 = new Teacher("Riya"); p1.role(); p2.role(); } }

This example demonstrates:

  • Class and object
  • Inheritance
  • Abstraction
  • Runtime polymorphism

Advantages of OOPS

  • better code organization
  • high reusability
  • easy maintenance
  • better real-world mapping
  • improved scalability
  • safer code through encapsulation

Limitations of OOPS

  • can be complex for small programs
  • requires good design thinking
  • too many objects may increase complexity
  • poor OOPS design can make code harder instead of easier

Common Mistakes

  • Confusing class with object
  • Using inheritance where composition is better
  • Breaking encapsulation by exposing data directly
  • Creating too many unnecessary classes
  • Using abstraction without clear design purpose

Best Practices

  • Use classes to model real-world entities clearly
  • Prefer encapsulation for data safety
  • Use inheritance only for true IS-A relationships
  • Prefer HAS-A when composition fits better
  • Keep classes focused on one responsibility
  • Design with maintainability and reuse in mind

Interview-Oriented Points

  • OOPS stands for Object-Oriented Programming System
  • Main fundamentals are class, object, encapsulation, inheritance, polymorphism, and abstraction
  • IS-A represents inheritance
  • HAS-A represents containment relationship
  • Encapsulation hides data, abstraction hides complexity
  • Polymorphism means one interface with multiple implementations
  • OOPS improves modularity, reusability, and maintainability

Conclusion

OOPS is the foundation of Java programming. It helps developers think in terms of objects, relationships, and reusable designs instead of only writing procedural code.

Understanding OOPS fundamentals, models, relations, and principles is essential not only for interviews but also for writing clean and scalable Java applications in the real world.

Quick Summary: OOPS organizes software around classes and objects, supported by principles like encapsulation, inheritance, polymorphism, and abstraction, along with relationships such as IS-A and HAS-A.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators