Can we execute a program without main() method?
In Java we can execute the program without main method can we give some examples??
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mukil VendhanPosted Aug 11, 2017, 10:57 AM
Yes, sequence is as follows:
So, if there's code in a static block, it will be executed. But there's no point in doing that.
How to test that:
Then if you try to run the class (either form command line with
java Testor with an IDE), the result is:Rajkiran SwainPosted Jun 28, 2017, 11:51 AM
Manikandan MurugesanPosted Jun 28, 2017, 10:22 AM
Guest UserPosted Jun 28, 2017, 5:26 AM
Vivek KumarPosted Jun 28, 2017, 3:14 AM
Naveen ArumugamPosted Jun 28, 2017, 3:02 AM
Mobeen RashidPosted Jun 23, 2017, 2:55 AM