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

Differentiate between postfix and prefix operators in java.

1184


Explain an algorithm to find depth of a binary tree.

1105


Why is the singleton pattern considered to be an anti pattern?

946


How do you reverse a string in java without using string buffer?

1149


What is the difference between an interface and an abstract class?

1054


What is the difference between final, finally and finalize()?

1244


Can we execute a program without main() method?

1090


Is it possible to compare various strings with the help of == operator? What are the risks involved?

1131


What is the purpose of default constructor?

1039


Can a constructor have different name than a class name in java?

1283


how its run?

1118


Can array grow dynamically in java?

1032


What’s the difference between applets and standalone program?

1110


What do you mean by order of precedence and associativity?

996


Do I need java on my pc?

1112