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

What are static blocks in java ?

0 Answers  


Where is singleton pattern used?

0 Answers  


how to print hello world every second till i have pressed enter key ???

1 Answers   SAP Labs,


How many bytes is a character?

1 Answers  


what is request processor?

1 Answers   Virtusa,






Suppose there is an array list [10,5,20,19,15,24].Print them in ascending & descending order in collection framework concept ???

2 Answers   Cognizant,


How many decimal digits is 64 bit?

0 Answers  


What are green threads in java?

0 Answers  


What occurs when an object is constructed?

0 Answers  


Can we have more than one package statement in the source file?

0 Answers  


What is lastindexof in java?

0 Answers  


How do you square a number?

0 Answers  


Categories