Difference between Encapsulation and Abstraction

Answers were Sorted based on User's Feedback



Difference between Encapsulation and Abstraction..

Answer / 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

Difference between Encapsulation and Abstraction..

Answer / malleswari

Abstract is provide necessary properties and operation of
an entity.Encapsulation is binding properties and operation
to an entity.

Is This Answer Correct ?    5 Yes 1 No

Difference between Encapsulation and Abstraction..

Answer / prashant

abstrction in simple language is making complex thing simple
to use by using small and simple controls.
example:- as we know that the car is made up of many
complicated parts.but without bothering the internal details
of car we can drive using accelerator,break and clutch.in
this example accelarator,break and clutch are the small
controls,which makes possible to operate compicated car


encasulation is a method of defining data members and method
together within a class.

Is This Answer Correct ?    1 Yes 0 No

Difference between Encapsulation and Abstraction..

Answer / srikanth

Data abstraction is one part of the data
encapsulation....that means data hiding...by achieving data
abstraction by
1)group of similar variables and methods is called
class...so one class variables and methods are hide to
another....
2)by using access specifiers

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Core Java Interview Questions

How can I debug the Java security exceptions and AccessControlExceptions?

0 Answers   IBM,


How do you check if two strings are equal in java?

0 Answers  


what is polymorhism what is inheritance? what is Abstract n Interface? what if two interfaces have same method and a concrete class is implementing both the interfaces. Will there be a compilation error? What are mutable and immutable classes? How can u make a class mutable? when will u use dem ...explain with example? what is overriding and overloading? what is garbage collection? what is Thread? how do dey communicate? what are the different ways of implementing ? have u used any messaging technologies? what is synchronization? what are some additions in java 1.5? what are generics? whst is advanced for loop? what is finally block? can u have a try in finally? yes!! can u have a finally in finally? how do you write junits? when is a object eligible for garbage collection?explain? a = null and b has ref to a will b be eligible to be garbage collected? sql questions like diff joins? how do dey work? exception handling? what is marker interface? what is the need??

0 Answers   JPMorgan Chase,


What are the differences between include directive and include action?

0 Answers  


What if static is removed from main method?

0 Answers  






What is outofmemoryerror in java?

0 Answers   Cyient,


Difference between arraylist and vector.

0 Answers  


What is the default access specifier for variables and methods of a class?

0 Answers  


Can private method static?

0 Answers  


What is object

6 Answers  


which swing component is similar to rich text box in .net/vb

1 Answers  


Explain treeset?

0 Answers  


Categories