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 difference between null and void?
Explain about fail safe iterators in java?
Why arraylist is used in java?
Why is logger singleton?
Does string is thread-safe in java?
What is maximum size of arraylist in java?
What do you mean by a JVM?
What is bytecode in java ?
What is backdrop?
Where to store local variables?
What is an object class?
What is the difference between JDBC 1.0 and JDBC 2.0?
Write a program in java to create a doubly linked list containing n nodes.
How do you compare two strings lexicographically?
What does it mean that strings are immutable?