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?

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / ravikiran(aptech mumbai)

the variable declared as private can be accessed with in the
same class only

Is This Answer Correct ?    2 Yes 2 No

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

Answer / neo

You can access the private variable in to the other package
or other classes by inheritance . to inherite the super
classes all the resources comes in to sub classes private
also in this context.

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More Core Java Interview Questions

What is the inheritance?

0 Answers  


How to decrease number of hashings in has

1 Answers  


What is a java string?

0 Answers  


What state does a thread enter when it terminates its processing in java programming?

0 Answers  


Why you should not use singleton?

0 Answers  


wat is class level lock and object level lock

3 Answers   HCL, Persistent,


what is Remote Reference Layer ?

1 Answers  


What is singleton math?

0 Answers  


Can an interface be defined inside a class?

0 Answers  


Why Set interface contains unique elements, what internally implemented for this so that it contains unique elements?

1 Answers   Rolta, TCS,


what is static import in java? Explain

0 Answers  


What is parsing in java?

0 Answers  


Categories