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 string args [] in java?
Is java based on c?
What are different types of encoding?
Is string is a keyword in java?
What is module in oop?
Can we convert stringbuilder to string in java?
how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? : Java thread
What is a final class ?
What is volatile data type?
Implement a stack with push (), pop() and min() in O(1) time.
What is hashmap in java?
what are Hostile Applets?
What is floor math?
What is a static class in java?
What is rule of accessibility in java?