Data Hiding
The data should not go out directly i.e outside person is not allowed to access the data this is nothing but “Data Hiding”.
The main advantage of data hiding is we can achieve security.
By using private modifier we can achieve this.
Abstraction
Hiding implementation details is nothing but abstraction
Note:- 1) If we don’t know about implementation just we have to represent the specification then we should
go for interface
2) If we don’t know about complete implementation just we have partial implementation then we
should go for abstract.
3) If we know complete implementation and if we r ready to provide service then we should go for
concrete class
Encapsulation
If a class follows data hiding and abstraction such type of class is said to be ‘Encapsulated’ class.
Encapsulation = Data Hiding + Abstraction
The data members we have to declared as private. So that outside person is not allowed to access to directly
we have to provide Access to our data by defining setter and getter methods. i.e hiding data behind methods
is the central concept of encapsulation.
IS – A RelationShip
Also known as ‘inheritance’.
By using extends keyword we can implement inheritance.
The main advantage is reusability.
Note:- parent class reference can be used to hold child class object but by using that reference we r not
allowed to call child class specific methods.
HAS – A RelationShip
Also known as Composition or Aggregation .
There is no specific keyword, but most of the cases we can implemented by using new keyword.
Main advantage is reusability.
The data should not go out directly i.e outside person is not allowed to access the data this is nothing but “Data Hiding”.
The main advantage of data hiding is we can achieve security.
By using private modifier we can achieve this.
Abstraction
Hiding implementation details is nothing but abstraction
Note:- 1) If we don’t know about implementation just we have to represent the specification then we should
go for interface
2) If we don’t know about complete implementation just we have partial implementation then we
should go for abstract.
3) If we know complete implementation and if we r ready to provide service then we should go for
concrete class
Encapsulation
If a class follows data hiding and abstraction such type of class is said to be ‘Encapsulated’ class.
Encapsulation = Data Hiding + Abstraction
The data members we have to declared as private. So that outside person is not allowed to access to directly
we have to provide Access to our data by defining setter and getter methods. i.e hiding data behind methods
is the central concept of encapsulation.
IS – A RelationShip
Also known as ‘inheritance’.
By using extends keyword we can implement inheritance.
The main advantage is reusability.
Note:- parent class reference can be used to hold child class object but by using that reference we r not
allowed to call child class specific methods.
HAS – A RelationShip
Also known as Composition or Aggregation .
There is no specific keyword, but most of the cases we can implemented by using new keyword.
Main advantage is reusability.
No comments:
Post a Comment