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
What is the use of set in java?
Is singleton class immutable?
What is keyword in oop?
How do you format in java?
What is class forname used for?
What are the different types of methodologies?
Is java a prime method?
What are the characteristics of java?
What is entry set in java?
What will be the default values of all the elements of an array defined as an instance variable?
What is data string?
How do you calculate square roots?
what is the difference between a threads start() and run() methods? : Java thread
What is a platform?
What are the differences between processes and threads?