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
Explain java thread life cycle.
what are the methods in object?
Can we have more than one package statement in the source file?
Which package has light weight components in java programming?
What are the different ways to handle exceptions?
How do you insert a line break?
Does unicode support all languages?
What is the difference between access specifiers and access modifiers in java? 16
What is a double vs float?
Difference between error and exception
Explain the importance of finally over return statement?
Is there is any difference between a scrollbar and a scrollpane?
How many bytes is a url?
What is == and === in javascript?
What is identifier give example?