OOPs in Java

Anagha Shenoy
2 min readJun 14, 2023

--

Object Oriented Programming in Java

A Notebook and a Pen on a Laptop | Learning

OOPS is an acronym for “Object-Oriented Programming System.” It refers to the paradigm and system of organizing and designing software applications based on objects, classes, inheritance, polymorphism, and other related concepts. OOPS is a broader term that encompasses the principles and practices of object-oriented programming across different programming languages.

Object-Oriented Programming (OOP) is a programming paradigm that focuses on organizing and structuring code around objects, which are instances of classes. It is a way of designing and building software applications by representing real-world entities or concepts as objects.

Objects and Classes — In Java, everything revolves around objects. An object is an instance of a class, which is a blueprint or template for creating objects. Classes define the properties (attributes) and behaviors (methods) that objects of that class will have.

In OOP, objects are the fundamental building blocks. They encapsulate data (attributes or properties) and behavior (methods or functions) related to a specific entity or concept. Objects interact with each other through methods, which can access and manipulate the object’s data.

The Key Principles are:

  1. Encapsulation: Encapsulation bundles data and methods together within a class, hiding the internal details of how an object works and exposing only necessary interfaces to interact with the object. It provides data protection and ensures that the object’s state remains consistent.
    It provides data hiding and protects the internal state of an object from direct access by other code. Access to the data is controlled through methods, known as getters and setters.
  2. Inheritance: Inheritance allows classes to inherit properties and behaviors from other classes, establishing a hierarchical relationship. A subclass (derived class) can extend or specialize the features of its superclass (base class). This promotes code reuse and enables the modeling of “is-a” relationships.
    It enables code reuse and establishes a hierarchical relationship between classes. A subclass (derived class) inherits the members of its superclass (base class) and can extend or override them.
  3. Polymorphism: Polymorphism allows objects of different classes to be treated as objects of a common superclass. It provides a way to write code that can work with objects of multiple types. Polymorphism is achieved through method overriding and method overloading, enabling dynamic binding and flexibility in program design.
  4. Abstraction: Abstraction focuses on defining essential attributes and behaviors while hiding unnecessary details. Abstract classes and interfaces provide a way to create abstract types that cannot be instantiated but can be used as base classes or implemented by other classes. Abstraction helps manage complexity and provides a clear interface for interacting with objects.

By using OOP, software developers can create modular, extensible, and maintainable code. OOP promotes code organization, reusability, and separation of concerns. It allows for modeling real-world entities, relationships, and behaviors, making the code more intuitive and easier to understand.

--

--