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...

Can you call a private data from an inner class?

Answer Posted / jettimadhuchowdary

public class MainTest {
private int localPr =1;
public int localPb = 20;
protected int localPro = 3;
int localDf = 5;
/**
* @param args
*/
public static void main(String[] s) {
// TODO Auto-generated method stub
MainTest mainTest = new MainTest();
InnerClass class1 = mainTest.new InnerClass();
class1.call();
}
class InnerClass
{
void call() {
System.out.println(" display data localDf ="+ localDf);
System.out.println(" display data localPro ="+ localPro);
System.out.println(" display data localPb ="+ localPb);
System.out.println(" display data localPr ="+ localPr);
}
}

}

and the output is

display data localDf =5
display data localPro =3
display data localPb =20
display data localPr =1

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is intern method in java?

1060


What is the static keyword?

1072


Can java list contain duplicates?

993


What is a generic type?

998


How do you implement polymorphism in our day to day life?

3214


Is there any difference between synchronized methods and synchronized statements?

1083


What is increment in java?

948


What comes to mind when someone mentions a shallow copy in java?

1099


Explain about the select method with an example?

1155


Does java support function overloading, pointers, structures, unions or linked lists?

1086


What is difference between final and finally in java?

1064


What is meant by main method?

1044


What is the definition of tree ?

1015


Can we call virtual funciton in a constructor ?

2182


What is the difference between class forname and new?

988