Friday, November 2, 2012

What Are The 4 Major Principles Of Object Oriented Programming

4 Major Principles Of Object Oriented Programming


Four principles of object oriented programming:
  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism
Abstraction :

“An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of object and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer.” — G. Booch, Object-Oriented Design With Applications

Abstraction is a way to generalize an object and write code for the generalized object.
Abstraction in Java is implemented using abstract class and interface.

Encapsulation :

Encapsulation is the ability to hide data from users and provide only the necessary details.
Encapsulation in Java is done by making the data member Private.

Inheritance :

A technique to create specialized classes from a general class.
Inheritance in Java is achieved using the keyword extends for classes and implements for interfaces.

Polymorphism :

Refers to an object’s ability to behave differently depending on the context.
Method Overloading is an example of Polymorphism in Java.

No comments:

Post a Comment