Monday 7 November 2016

JAVA Abstraction Vs Encapsulation

ABSTRACTION Vs ENCAPSULATION 


Both are a design and compliments each other.
Abstraction design tells , you should "Show only necessary" menthods to user of your class and Encapsulation tells "Hide All the complexity" of your class.

Abstraction:

Say

Public class Employee {

public void updateSalary() // this one is Public and will be exposed to world

 #Some private property 
 This interns calls 
 getSalary() --> Private
 checkCreditLimits(), // Private
#and other API 

}

Encapsulation

Here  #Some private property will never be visible to user of this class/object


No comments:

Post a Comment