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

Explain the differences between public, private, protected
and static?

Answer Posted / ranganathkini

Members marked public are accessible to members of any class
irrespective of the package.

Members marked private are only accessible to other members
of the same class.

Members marked protected are only accessible to other
members of the same class, members of a subclass and members
of other classes in the same package.

Member marked static are shared by all instances of that
class and hence r not related to any specific instance of
that class. Methods marked static cannot access non-static
members or fields of that class. But non-static members can
access static fields or methods.

Is This Answer Correct ?    111 Yes 21 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In case of inheritance what is the execution order of constructor and destructor?

1057


What is the do while loop syntax?

982


What are the 8 primitive data types in java?

972


What is the memory leak in java?

968


what do you understand by synchronization? Or what is synchronization and why is it important? Or describe synchronization in respect to multithreading? Or what is synchronization? : Java thread

882


Can you override private or static method in java?

931


What is public static?

978


What is the main purpose of serialization in java?

972


Is object a data type in java?

1050


What is hashtable and explain features of hashtable?

946


Is char * a string?

936


Can a final variable be null?

956


What are the practical benefits, if any, of importing a specific class rather than an entire package (e.g. Import java.net.* Versus import java.net.socket)?

1078


What's the purpose of using break in each case of switch statement?

930


How can we achieve thread safety in java?

1086