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
What is difference between calling start() and run() method of thread?
What is java Applet?
String and stringbuffer both represent string objects. Can we compare string and stringbuffer in java?
What are the differences between getting and load method?
What kind of variables a class can consist of?
Write a program to find the greatest of three numbers in java?
how does multithreading take place on a computer with a single cpu? : Java thread
What is data string?
What is mutable object and immutable object?
What are the advantages of java?
What type of variable is error flag?
how to write a program for sending mails between client and server
Is hashset ordered java?
What is sleep method?
java Technical questions asked by JPMC