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 access modifiers can be used for variables?

0 Answers  


What modifiers are allowed for methods in an interface?

0 Answers  


What is the multilevel inheritance. and also give the Example of it ?

5 Answers  


what is mutability?which one is mutable String or StringBuffer?and why?give examples of each which shows the mutability of each String or StringBuffer

4 Answers   IBM, Zenon,


What are the types of methods in java?

0 Answers  


What are the three parts of a lambda expression? What is the type of lambda expression?

0 Answers  


Can you declare the main method as final?

0 Answers  


why applet doesn't have main? isn't possible a program with out main?

9 Answers   TCS,


what is meaning of JIT?

4 Answers  


Difference between Superclass and Subclass?

7 Answers  


Write java program to reverse string without using api?

0 Answers  


Can arraylist contain null values?

0 Answers  


Categories