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 nested class in java?
Which collection is sorted in java?
What is a cup of java?
Define class?
Describe 2 different ways to concatenate two strings.
What is array command?
What are the wrapped, classes?
What is the purpose of the main method?
Explain the importance of import keyword in java?
What do you mean Abstraction in java?
What does it mean that a class or member is final?
What is nan in java?
What is covariant return type?
Is void a return type?
What are variable names?