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 to give the file name same as the public class name in
java?

Answer Posted / naresh kumar

If u dont keep public in front of class that is not
accessible by third party packages. But if u keep public
infront of class that is accessible by third party
packages.

Problem: class CheckServlet extends HttpServlet
{---- }
Now u want to executed this servlet class in server
(Tomcat,WebSphear,WebLogic) an error will come .Because the
above class is comes under default access modifier.

Ans: public class CheckServlet extends HttpServlet
{-------}
This class services will executed in any server(either
Tomcat,WebLogic etc.,). Because The class is visible in
third party class packages like container packages.

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which class is the superclass for all the classes?

1019


Is null or empty java?

976


Which sorting algorithm is in place?

959


Which collection is sorted in java?

1032


What is the map interface in java programming?

1010


Explain methods specific to list interface?

968


What are the types of arrays in java?

1077


Is singleton class immutable?

961


What is the purpose of extern variable?

1014


What are the four integer types supported by java?

1028


Explain some best practices you would apply while using collection in java?

1025


What is boolean logic?

1010


Is it possible to cast an int value into a byte variable? What would happen if the value of int is larger than byte?

945


What is the range of the short type?

1016


What are the methods of object class ?

1049