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
Which class is the superclass for all the classes?
Is null or empty java?
Which sorting algorithm is in place?
Which collection is sorted in java?
What is the map interface in java programming?
Explain methods specific to list interface?
What are the types of arrays in java?
Is singleton class immutable?
What is the purpose of extern variable?
What are the four integer types supported by java?
Explain some best practices you would apply while using collection in java?
What is boolean logic?
Is it possible to cast an int value into a byte variable? What would happen if the value of int is larger than byte?
What is the range of the short type?
What are the methods of object class ?