Can main() method in Java return any data?

1 votes
468 views
Anonymous User asked 20-Dec-2017 in Technology by Anonymous User

Can main() method in Java return any data?

1 Answer

0 votes
Harsh kumar srivastava answered 20-Dec-2017 by Harsh kumar srivastava

No, main() method in Java can't return any data that's why it's declared with a void return type. The compiler would not compile it as it is expecting the return type of main to be int, hence we can overload it.

Well, for your knowledge Main () Method is validated only when its return type is Void. Any other substitute is not adequate.

Hope it's informative...