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

How to access a variable if it is declared as private?

Answer Posted / ranganathkini

If a variable inside a class is marked private then it
cannot be accessed directly.

Access to this variable can only be provided by a public
accessor and mutator methods. Example:

class MyClass {
private int dataValue;

public int getDataValue {
return dataValue;
}

public void setDataValue( int newValue ) {
dataValue = newValue;
}
}

Is This Answer Correct ?    7 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why java is call by value?

1032


Why string is immutable or final in java

1088


What is nan in java?

997


What is string data type?

975


What is string data?

984


Give few difference between constructor and method?

966


Why char array is preferred over string for storing password?

1106


Is arraylist dynamic in java?

994


How many bits is a string?

1005


Can a main method be declared final?

1057


What are inbuilt functions in java?

1087


What is keyword in oop?

953


Explain the access modifiers for a class, method and variables?

1142


List the features of java programming language.

1053


What is jpa specification?

987