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 sleep method?
What is bigger kb or mb?
Java openings 3 - 5 years, Lnt Infotech. requirements - core java, J2ee, struts, hibernate Interview Date:- 19 March 2011 Time:- 9:00 AM to 12:00 Pm Interview Location - L & T Infotech, Manapakkam, Chennai Refererral PS NO:- 291649 (Please mention this when u fill the form only then u will be considered for interview) Documents Required:- Latest Resume, Photograph and last 3 payslips Mail me on vasan2211@gmail.com once u appear for interview
Can we convert list to set in java?
How can we make copy of a java object?
What is the difference between array list and vector in java?
What is a loop java?
Explain different forms of polymorphism?
How do you square a number in java?
How does hashset work in java?
What is synchronization and why is it important in java programming?
Is void a return type?
What is java volatile?
How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters in java programming?
Which are different kinds of source code?