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 happens to the Exception object after handling an exception?
What is the purpose of the finally clause of a try-catch-finally statement in java programming?
What happens when you add a double value to a string?
Is ruby built on java?
What does a boolean method return?
Addition to previous section relative word 5th one was Putrid ans: rotten, also there was prob. in 1st section on bucket weight ans:10kg, also there was a prob. on train speed to find bridge length ans:800 mtrs.
What is array pointers ?
What are the different access modifiers available in java?
Why does the integer quotient -0/3 yield 0, but the double quotient -0.0/3.0 yields – 0.0?
What is outofmemoryerror in java?
Write a program to find maximum and minimum number in array?
Is there any difference between nested classes and inner classes?
Are private methods final?
How to make a write-only class in java?
Explain importance of inheritance in java?