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 function and its uses?
How do you declare an array that will hold more than 64KB of data?
What is <> used for in java?
Difference between process and thread?
What is independent and dependent variables in research?
What is the constructor?
Difference between stack and queue?
What is java and why do we need it? Explain
Why method overriding is used?
What are the basic control structures?
Explain about member inner classes?
What is the difference between an object-oriented programming language and object-based programming language?
What are the different tags provided in jstl?
What does a boolean method return?
What is anagram of a string?