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

Can constructor return value?

971


Can we use switch statement with strings?

1046


Can we override the private methods?

1012


What is the difference between and ?

1018


Difference between class#getinstance() and new operator ?

1213


What are the procedures?

1061


Define linked list and its features with signature?

1005


Can a constructor be made final?

1113


Why do we need strings in java?

995


What is the program compilation process?

1118


how to create daemon thread in java?

1080


Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?

994


What is basic syntax?

1046


What is a jit compiler?

1136


What are the types of arrays in java?

1090