Is it possible to compile and run a Java program without writing main( ) method?

Search Interview Questions

 3358 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text


Java - Interview Questions and Answers

 Q1. Is it possible to compile and run a Java program without writing main( ) method?
Ans. Yes, it is possible by using a static block in the Java program.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   main   static block   compile   yes-no

Related Questions

  How does volatile affect code optimization by compiler?
  How compiler handles the exceptions in overriding ?
  Which of the following is false about Constructors ?
  Is JVM, a compiler or interpretor ?
  If we try to add duplicate key to the HashMap, What will happen ?
 Why doesn't this code give compile time error when we are clearly trying to add an integer element to an array of Strings

Object[] strArray = new String[2];
strArray[0] = 5;
  Will Compiler creates a default no argument constructor if we specify only multi argument constructor ?
  What is the difference between compile and install ?
  Will this code compile ?

Subscribe to Java News and Posts. Get latest updates and posts on Java from
Enter your email address:
Delivered by FeedBurner

comments powered by Disqus

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:

X Close this