Sunday, February 9, 2020

Key Concepts in OOP using Java


OOP concept in JAVA is main objective behind Java Object Oriented Programming. 
The main four concepts are
1.     Abstraction
2.     Encapsulation
3.     Polymorphism
4.     Inheritance


Each concept is explained below in detail-
1.     Abstraction –Abstraction means representing complexity using simple terms. It means, show the relevant data and hide the unnecessary data of object from user. We all know turning ON television but how it operates internally according to our wish list we don’t know same is related to abstraction. Hides the internal working. Objects, classes and variables are simple terms in Java which represent complex codes and data. Use of this, helps to avoid repeated use of same lines multiple times.
2.     Encapsulation –Encapsulation is the practice of keeping the fields i.e data in private class, then giving access via public call methods. It is basically used for protecting the data and code safe within class itself .It’s a protective barrier. Using this we can reuse objects of code without giving open access system-wide.\
Characteristics required for encapsulated code-
 1. Everyone knows how to access it.
 2. Can be easily used regardless of implementation details.
 3. There should not be any side effect of code, to rest of application.
3.     Inheritance- It is special feature of OOP in Java .It allows to create new classes that share some attributes of existing classes. This helps to build on previous work without recreation of new procedure. Inheritance also means acquiring properties of another objects. It supports hierarchal classification. JAVA swing and AWT classes are best examples of inheritance.
4.     Polymorphism- Using polymorphism same word to mean different context can be used. Two forms of polymorphism are present in Java , those are method overloading and method overriding.
Method Overloading means different meanings implied by same code itself.
Method Overriding means different meanings implied by values of supplied variables.

Diksha Avhad
K-03




14 comments: