What is meant by encapsulation ? Explain with an example.

What is meant by encapsulation ? Explain with an example.

Binding up the data and methods into a singleunit, i.e. class is called encapsulation.

 Example:

 class Area{ //data variable double dim1; 

 double dim2;

 //methods public double calculateArea(double d1,double d2){ //some calculation code here}}


By:Jalees
Date:2012-01-09 00:00:00

Binding up the data and methods into a singleunit, i.e. class is called encapsulation.

 Example:

 class Area{ //data variable double dim1; 

 double dim2;

 //methods public double calculateArea(double d1,double d2){ //some calculation code here}}


By:Sumit Tripathi
Date:2019-05-15 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher