Why to give the file name same as the public class name in
java?
Answers were Sorted based on User's Feedback
Answer / akanksha bansal
So that ,that class is accessible from some other class/file
as well
Is This Answer Correct ? | 10 Yes | 2 No |
Answer / mahesh
First of all, it only has to be the same when the class is
public. And there is no explicit reason for that, it's just
a convention that came along with old versions of java and
people got used to it... They say it's because of the
limited capabilities of the compiler to compile
dependencies.
Is This Answer Correct ? | 9 Yes | 4 No |
Answer / 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 |
Explain about GridBag Layout?
Can subclass overriding method declare an exception if parent class method doesn't throw an exception?
I declared main() method as private. But it still running and displaying the output. Please Answer it . Code Snippet as Below: import java.io.*; class over { private static void main(String[] args) { int high = Integer.MAX_VALUE; int overflow = high + 1; int low = Integer.MIN_VALUE; int underflow = low - 1; System.out.println(high + "\n" +overflow +"\n"+ low +"\n"+underflow); //System.out.println(overflow); //System.out.println(low); //System.out.println(underflow); } }
What is a instance variable?
What is the purpose of having the concept of overloading?
What is the integer of 16?
Why java is platform independent? Explain.
What do you mean by boolean?
What is “try and catch” in java
How Array List can be Serialized.
What is difference between add() and addelement() in vector?
How to sort numbers in java without array?