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
when to use ArrayList and when to use HashMap in webApplication.
Can we have a try block without catch block?
What is the main functionality of the remote reference layer?
Define how destructors are defined in java?
What is the current version of java?
What is collection class in java? List down its methods and interfaces.
Write a program to find the whether a number is an Armstrong number or not?
What is a Transient Object?
What is the meaning of 3 dots in java?
Can we declare a class as abstract without having any abstract method?
Can inner class be public in java?
What is a protected class in java?
What is the use of default method in interface in java?
Why is string class considered immutable?
What is the difference between the file and randomaccessfile classes?