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

Why only one Class is public in one file? Explain in
details. Thanks in Advance.

Answer Posted / sadhi

In java we have 4 specifiers i.e:
1.public
2.private
3.protected
4.default
public: we can access these instance variables and instance
methods at out side the class and inside the class.
2.private:using this specifier only we can access with in
the class. there is no possibility to access the outside.
3.protected:we can access the class with in the package.
4.default:Is generally act as public when we not specify
anything specifier.

so,we can use public class any where that mean these
variables and methods accessed by another class that's why
there is no need to create more public classes in single file

Is This Answer Correct ?    8 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Are global variables initialized to zero?

916


What is stringwriter?

913


List out benefits of object oriented programming language?

839


What is the simpletimezone class in java programming?

1089


What is the difference between path and classpath variables?

981


Explain notifyall() method of object class ?

1055


What are the 4 versions of java?

1112


Why map is used in java?

990


What is multithreading and its advantages?

1021


What are the characteristics of java?

990


What is double checked locking in singleton?

1011


I want my class to be developed in such a way that no other class (even derived class) can create its objects. How can I do so?

940


What is :: operator in java 8?

962


What is bufferedreader in java?

1008


What is the difference between interface & abstract class?

993