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 the gregoriancalendar class in java programming?
Is java developer a good career?
What are the advantages of exception handling in java?
How static variable work in java?
Can you have two constructors in java?
Is java good for beginners?
How to sort array in descending order in java?
What is the major advantage of external iteration over internal iteration?
What are dot operator queries?
What is busy spin, and why should you use it?
What is meant by attribute?
Difference between method overloading and overriding.
Can the interface be final?
What is the difference between a static and a non-static inner class in java programming?
What are constants and how to create constants in java?