Java OOP’s (Java Object Oriented Programming)

Krishna Bankar
4 min readFeb 7, 2021

Outlines for OOP’s :

  1. Introduction
  2. OOP’s concepts (four fillers of OOP’s) :
    i. Abstraction
    ii. Encapsulation
    iii. Polymorphism
    iv. Inheritance
    — single inheritance
    — multilevel inheritance
    — multiple inheritance
    — hybrid inheritance
    — hierarchical inheritance
  3. Conclusion
  4. References

1. Introduction :

OOP’s stands for Object Oriented Programming. It is a computer programming model that organizes software design around objects, rather than functions and logic . OOP’s talks about object and class. Class is a structure or blueprint for an object and for a class there can be many objects. Class declares attributes and behaviour of object and object is a physical or real world entity.

For example : a girl and an iphone are two objects:

Iphone
Iphone Object

Iphone is real world entity for class Iphone class.

Iphone Class
girl Object

girl is real world entity for Girl class

Girl Class

2. There are four OOP’s conceps (four pillers of OOP’s) :

2.i. Abstraction :

Abstraction is the process of hiding code or sensitive information and showing only ordinary or human readable information.

Using abstract class and interface we can implement abstraction.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

2.ii. Encapsulation :

It is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit. we can implement encapsulation by private data and getter, setter methods.In encapsulation, the variables of a class will be hidden from other classes and can be accessed only through the methods from the main class.

2.iii. Polymorphism :

Polymorphism means “many forms”, and it occurs when we have many classes with same method signature that are related to each other by inheritance.
There are two types of polymorphism in Java :

  1. Compile time polymorphism
  2. Runtime polymorphism
note: methods must be static. based on ref. variable of class method will be executed.

1.Compile time polymorphism
Where method resolution Is always taken care of by the compiler based on reference type.

note : methods are instance / non-static. based on the runtime object of class method will be executed.

.

.

.

.

.

.

.

.

.

2. Runtime polymorphism :
Where method resolution Is always taken care of by JVM based on runtime object.

.

.

.

.

.

.

.

.

Note : For both polymorphism If the child class does not have a method then parent class method will be executed

2.iv. Inheritance :

Inheritance is a mechanism in which child object acquires all the properties and behaviours of a parent object and child object also contains extra properties itself.

There are 4 types of inheritances :
a. single inheritance
b. multiple inheritance
c. multilevel inheritance
d. hybrid inheritance
e. hierarchical inheritance

2.iv.a. Single inheritance :

In single inheritance child class inherits a single parent class property.

.

.

.

.

.

.

.

.

.

.

.

.

2.iv.b. Multiple inheritance :

In multiple inheritance a child class inherits property of two or. more parent classes.

.

.

.

2.iv.c. Multilevel inheritance:

In multilevel inheritance a child class inherits property of his parent class, grand parent class and further more parent.

.

.

.

.

2.iv.d. Hirarchycal inheritance :

In hirarchical inheritance a parent class inherits by more than one child classes.

.

.

.

2.iv.e. Hybrid inheritance :

In hybrid inheritance a child class inherits his all parent classes and more than one parent classes also this child class property inherited by its child classes.

.

.

.

.

3. Conclusion :

As we have discussed all features of OOP’s even java is not a pure object oriented programming language. Java does not support multiple inheritance, so automatically hybrid inheritance will not be supported by java. All user defined types are not objects like primitive data types and all operations in java must be in methods but because of static keyword operation can be out of method too.

4. References:

Reference for further more reading about OOP’s:
1. https://blog.propel.school/object-oriented-programming-in-java
2. https://www.freecodecamp.org/news/object-oriented-programming-concepts-21bb035f7260/
3. https://www.w3schools.com/cpp/cpp_oop.asp
4. https://www.geeksforgeeks.org/object-oriented-programming-oops-concept-in-java/

--

--