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 functionability stubs and skeletons?
How does split work in java?
What is the purpose of the System class?
How does a for loop work?
How can we make sure main() is the last thread to finish in java program?
Which collections are thread safe in java?
What is the difference between == and === javascript?
What is the difference between variable & constant?
what is singleton class in java?
What is private static class in java?
Is a method a function?
What is a parent class in java?
What are different types of references?
a thread is runnable, how does that work? : Java thread
What is integer size in java?