Difference between Encapsulation and Abstraction

Answer Posted / balbir

encapsulation:wraping of data and method into single unit.
e.g:

public class Test {
private int id;
private int roll;

public void method(int i,int j){
id = i;
roll = j;
System.out.println("===id==="+id);
System.out.println("===roll==="+roll);
}
public static void main(String args[])
{
Test t =new Test();
t.method(100,200);
}
}

in above example privatevariable wrap with public
method,this is encapsulation.

Abstraction:hiding the implementation details from the
external users.
e.g: electric switch board is available for end user
without knowing the implementation details.means end user
not bother about what is the manufactored items inside th
switch board.this is called abstraction.

Is This Answer Correct ?    12 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of set in java?

610


Is singleton class immutable?

538


What is keyword in oop?

514


How do you format in java?

545


What is class forname used for?

538






What are the different types of methodologies?

526


Is java a prime method?

550


What are the characteristics of java?

520


What is entry set in java?

529


What will be the default values of all the elements of an array defined as an instance variable?

549


What is data string?

493


How do you calculate square roots?

570


what is the difference between a threads start() and run() methods? : Java thread

518


What is a platform?

538


What are the differences between processes and threads?

510