What is Concept of OOP’s? – Day 11

Published by Maneet Srivastav on

What is OOPs ???

OOPs stands for Object-Oriented Programming. An approach to do programming which is based on Objects (or real-life objects). All object-oriented programming languages provide mechanisms that help to implement the object-oriented model.

Object-oriented programming (OOP) is at the core of Java. In fact, all Java programs are to at least some extent object-oriented. OOP is so integral to Java that it is best to understand its basic principles before you begin writing even simple Java programs.

There are mainly six OOPs concepts in general.

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

Object

The object is a basic unit of OOPs and represents the real-life entities. A typical Java program creates many objects, which as we know, interact by invoking methods. An object consists of :

  • State: It is represented by attributes of an object. It also reflects the properties of an object.
  • Behaviour: Is is represented by methods of an object. It also reflects the response of an object with other objects.
  • Identity: It gives a unique name to an object and enables one objects to interact with other objects.

Class

A class is a user-defined blueprint or prototype from which objects are created. It represents the set of properties or methods that are common to all objects of one type. In general, class declarations can include these components, in order :

  • Modifiers
  • Class Name
  • Super-class (if any)
  • Interfaces (if any)
  • Body

Inheritance

Inheritance is an important pillar of OOPs. It is the mechanism in Java by which one class is allowed to inherit the features (fields and methods) of another class, the keyword used for inheritance is extends. Important terminology in it :

  • Super Class
  • Sub Class
  • Reusability

Types of Inheritance in Java :

  • Single Inheritance
  • Multi-Level Inheritance
  • Hierarchical Inheritance
  • Multiple Inheritance

Polymorphism

Polymorphism means ‘a state of having many shapes’ or ‘ability to take different form’.  When applied to Object-Oriented Programming, it describes a language’s ability to process objects of various types and classes through a single, uniform interface.

  • Static Polymorphism is achieved through method overloading.
  • Dynamic Polymorphism is achieved by method overriding.

Data Abstraction

Abstraction is a process of hiding the implementation details and showing only functionality to the user; for example, sending the message, we just type the text and send the message. We don’t know the internal processing about the message delivery.

  • A class that is declared as abstract keyword is known as abstract class. It needs to be extended and its instantiated. Example, abstract class a{}
  • The interface in java is a mechanism to achieve abstraction. There can be only abstract methods in java interface, not method body. Example, interface BrighterBees { int min = 5; void print(); }

Encapsulation

Encapsulation is the mechanism that binds together code and the data it manipulates and keeps both safes from outside interference and misuse.

It is implemented using access modifiers :

  • default
  • public
  • protected
  • private

CONNECT WITH THE AUTHOR ON LINKEDIN.

VISIT OUR WEBSITE BRIGHTERBEES FOR INFORMATION ABOUT JAVA.

TO GET ON THE BLOG OF DAY 7 OF THIS JAVA SERIES click here.

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

STAY CONNECT WITH US