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
Does java support multiple inheritance or not?
What are the benefits of operations in java?
What is an argument java?
What is the difference between JDK and JVM?
How do you reverse sort in java?
What is meant by null and void?
Explain about main() method in java ?
What are internal variables?
what is synchronization and why is it important? : Java thread
What is the difference amongst jvm spec, jvm implementation, jvm runtime ?
Can you use abstract and final both with a method?
What is the best way to findout the time/memory consuming process?
What is the use of static class?
What are disadvantages of java?
Write an algorithm program in java for the following question.. 1) S is a set of integers.X is an integer obtained by sum of two digits in S. Write logic for whether or not the X is from the S. The time of algorithm should not exceed o(n logn).