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 happens when I use / and % with a negative numerator?
Difference between notify() method and notifyall() method in java?
Hi friends am new to java. I read jar file means collection of java files. For executing struts application what are the necessary jar files. " struts.jar " file contains what. can u explain
What is null data type?
How do you change an int to a string?
What are decalarations?
What is the syntax and characteristics of a lambda expression?
What are different types of references?
How do you represent a space in regex java?
Is minecraft 1.15 out?
What are the methods available in a class?
Explain about OOPS concepts and fundamentals.
Can java hashmap have duplicate keys?
What is rule of accessibility in java?
Which programming language is most secure?