DEV Community

mohandass
mohandass

Posted on

Java-object oriented programming language(OOP)

What is object oriented programming

  • Object-Oriented Programming (OOP) is a software design model that organizes code around "objects" rather than logic or functions.

  • It groups related data (attributes) and behaviors (methods) into single, reusable units, making it ideal for managing large, complex, and collaborative software projects.

The Main Pillars of OOP

  • Class - A blueprint or template for creating objects.
  • Object - An instance of a class.
  • Encapsulation - protects data from direct access
  • Abstraction - Hides unnecessary details
  • Polymorphism -Allow the same method to behave differently
  • Inheritance - Reuses code from exciting classes

Class

  • Classes are user-defined data types and serve as the template for individual objects, properties, and actions.

  • A Class in Java is a blueprint or template used to create objects. It defines the properties (data) and behaviors (methods) that objects of that class will have.

  • A class is a user-defined data type.

  • It contains variables (fields) and methods.

  • Multiple objects can be created from a single class.

Example: A Car represents a class (blueprint), while BMW, Mercedes, and Audi represent objects (instances) created from that class.

Objects

  • Objects are instances of a class created with specifically defined data. Objects can correspond to real-world objects or an abstract entity. When class is defined initially, the description is the only object that is defined.

    • An actual instance of a class that exists in the computer's memory (e.g., your specific red sports car).

Inheritance

  • Inheritance is a core OOP concept in Java that allows one class to acquire the fields and methods of another class using the extends keyword. It represents an β€œis-a” relationship between classes.

  • An object of one class acting as an object of another class

  • Encapsulation - (TBD)

  • Abstraction - (TBD)

  • Polymorphism - (TBD)

REFERENCE :
https://www.techtarget.com/searchapparchitecture/definition/object-oriented-programming-OOP

https://www.geeksforgeeks.org/dsa/introduction-of-object-oriented-programming/

Top comments (0)