Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is encapsulation? Elaborate with example?



What is encapsulation? Elaborate with example?..

Answer / devarathnam.c,kotagudibanda,ka

Hi,
Encapsulation: The wrapping up of a data and methods into a
single unit is called Encapsulation. You can achieve
Encapsulation by using private data and public methods look
at the following example for better understanding.
Eg:
public class EcapTest{
public static void main(String args[]){
private int a=22;
private String s="DEVARATHNAM";
private float f=33.24f;

public void displayData(){
// some code
}
public void getData(){
// some code
}
}//main
{//class.

Observe the above program we are combining both data and
methods into a single unit(EcapTest). I hope i met your
needs.

Is This Answer Correct ?    23 Yes 5 No

Post New Answer

More Core Java Interview Questions

do I need to use synchronized on setvalue(int)? : Java thread

0 Answers  


Explain about serializable interface in java?

0 Answers  


what do you mean by stream pipelining in java 8? Explain

0 Answers  


What type of language is java?

0 Answers  


What is super in java?

0 Answers  


How can you traverse a linked list in java?

0 Answers  


Why Static variable required in java?For ex,class A { static int a; int b; } Why static is required?

5 Answers   Ericsson,


who can we create the object of a class? in how many ways we can create it (max 5)

2 Answers  


What is a serializable interface?

4 Answers  


Explain Connection Pooling?

3 Answers  


What is Remote Interface ?

6 Answers   CTS,


How is tree Mirroring implemented?

0 Answers   Fidelity,


Categories