What are the main 3 Object Oriented Programing (OOP) concepts?

Copied from [1] https://www.ibm.com/developerworks/library/j-perry-object-oriented-programming-concepts-and-principles/index.html [2] http://www.w3resource.com/java-tutorial/java-object-oriented-programming.php

Encapsulation, Inheritance, and Polymorphism

Encapsulation

Encapsulation means putting together all the variables (instance variables) and the methods into a single unit called Class. It also means hiding data and methods within an Object. Encapsulation provides the security. what's important is that the object maintains a boundary between its state and behavior and the outside world.

Inheritance

the ability to create classes that share the attributes and methods of existing classes, but with more specific features. Inheritance is mainly used for code reusability. vs POP: In structured programming, it's common to copy a structure, give it a new name, and add or modify the attributes that make the new entity (such as an Account record) different from its original source. Over time, this approach generates a great deal of duplicated code, which can create maintenance issues.

Polymorphism

In essence, polymorphism means that objects that belong to the same super-class when do the same thing, can manifest behavior differently.

  • Static Polymorphism (compile time polymorphism/ Method overloading)
  • Dynamic Polymorphism (run time polymorphism/ Method Overriding)