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

What happens if main method is not static?

0 Answers  


Differentiate constructor and a method and how are it be used?

7 Answers   Wipro,


What is the main purpose of java?

0 Answers  


What is implicit object in java?

0 Answers  


What is scope & storage allocation of static, local and register variables? Explain with an example.

0 Answers   IBS,


Does printwriter create a file?

0 Answers  


What is difference between null and void?

0 Answers  


Why are there no global variables in java?

0 Answers  


How do you get length in java?

0 Answers  


How many bytes is a url?

0 Answers  


Difference between class#getinstance() and new operator ?

0 Answers  


What is append in java?

0 Answers  


Categories