could you run the java program without main method?
Answer Posted / rammohan
with out main() and static block also run java program
through static obj creation
class nomainnostatic
{
nomainnostatic()
{
System.out.println("vaaniMohan");
System.out.println("hai");
System.exit(1);
}
static nomainnostatic n=new nomainnostatic();
};
support some jdk versions only
exp:when ever static obj is created the default constructor
will be called,so the constructor block will be executed.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is the private method modifier?
What is array length in java?
What is finally in Java?
What is the importance of hashcode() and equals() methods?
Why string is not a wrapper class?
What is the purpose of the finally clause of a try-catch-finally statement in java programming?
Is it compulsory for a try block to be followed by a catch block in java for exception handling?
Is upper case in java?
How to create a base64 decoder in java8?
What is a pointer and does java support pointers?
Is class forname reflection?
How can you set the applet size?
How can I debug the Java security exceptions and AccessControlExceptions?
What is palindrome in java?
What is the functionability stubs and skeletons?