Friday, June 7, 2019

OOP CONCEPTS - JAVA PROGRAMMING

Anu K Joy        
                             OOP  CONCEPTS
 (Object Oriented Programming)
                     
oops_java

The basic concepts of OOP are as follows :

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

1. Object

  • In Object-Oriented programming, Object is a basic unit and it represents the real life entities.
An Object consist of       

 -  Identity  (unique name to an object)

  - State ( represents the properties of an object)

   - Behavior(methods of an object)

Example of an object : Bicycle



2. Classes


  • In Object-Oriented programming, a class is a blueprint of  an object.
  • A class is a collection of objects of similar type.
  • For example : car,bike,scooter are members of the vehicle class.

3.Abstraction


  • Abstraction is representing important features by hiding  the implementation details.
  • The advantage of abstraction is that, the user can work only with the required data and does not need to view unwanted data and it helps to reduce programming  complexity and effort. 
Example of  Abstraction to understand the concept,
                                            A lady is driving a car, she only knows  that the accelerators will increase the speed of the car or applying brakes will stop the car but she doesn't know the inner mechanism of the accelerator  and the brake.This is what Abstraction is..

4.Encapsulation

  • Encapsulation means, binding variables and methods under single entity.
For Example a capsule which is mixed of several medicines.



5.Inheritance

  • Inheritance means, acquiring  the properties of one class to another class.
  • A class that is inherited from another class is called subclass or derived class or child class.
  •  The class from which the subclass is inherited is known as the superclass or the base class or parent class.



Now, let's look at figure.... Here, Class A is superclass and Class B is sub class.The subclass is derived from superclass that contains the combined features of both the classes.


There are  various types of inheritance in Java :

  1. Single Inheritance
  2. Multiple Inheritance
  3. Multilevel Inheritance
  4. Hierarchical Inheritance

6.Polymorphism

  • The term ' Polymorphism ' comes from two Greek words that is poly, meaning many and morphs meaning forms.
  • Therefore, polymorphism means, ' many forms'.

In Object-Oriented programming, polymorphism allows you to perform same method in different operation.

  • Polymorphism are of two types :

                                           1. Compile time polymorphism
                                           2. Run time polymorphism                                                   
The method Overriding is an example of Run time polymorphism and method Overloading is an example of Compile time polymorphism.


Hope you get the basic concepts of OOP. So we will discuss each concept in detail in coming blog.

2 comments:

If else statement in java ( with examples) - Java World

In this article, you will learn to use two selection statements: if and if else to the statements which alter the flow of  your program’s ...