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 java project architecture?
how to create multithreaded program? : Java thread
What is a stack class in java ?
What is treeset in java?
What happens when a thread cannot acquire a lock on an object in java programming?
How to check if linked list contains loop in java?
What are the 3 types of control structures?
What variables are stored in stack?
What is a jit compiler?
I don’t want my class to be inherited by any other class. What should I do?
What are features of java?
What is a line break example?
Break statement can be used as labels in java?
What is widening and narrowing in java? Discuss with an example.
Can we declare array without size in java?