Prepare for your Next Interview
This is a discussion on return type of main method within the Java forums, part of the Software Development category; Can we use 'int' as return type of main method in java?? like: public static int main(String args[])...
|
|||
|
Re: return type of main method
U can override , overload main()
like wt u said public static int main(String args[]){} but jvm checks for the entry point i.e public static void main(String args[]) if it finds jvm instance wil create otherwise fails the execution |
| The Following User Says Thank You to mamatha.cute For This Useful Post: | ||
|
|||
|
Re: return type of main method
no in java main method return nothing..
there is only valid signature of main method is public static void main(String[] args) |
| The Following User Says Thank You to kunal066 For This Useful Post: | ||
|
|||
|
Re: return type of main method
In java you can overload the main method so you can define another main method which returns int value but at the runtime JVM check for the main method that return void so if if does not find main method it throws an exception.
|
| The Following User Says Thank You to deeptiagrawal For This Useful Post: | ||
|
|||
|
Quote:
Two valid signature of main methods: public static void main(String[] prince) ![]() or static public void main(String[] prince) ![]() |
| The Following User Says Thank You to PRINCEJOHNWESLEY For This Useful Post: | ||
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| java program without main method | BHASKAR CHAUHAN | Java | 6 | 4 Weeks Ago 02:06 PM |
| applet using main method | manjula_p | Java | 1 | 02-12-2008 12:27 AM |
| Overload main method | Geek_Guest | Java | 6 | 01-22-2008 10:02 AM |
| Declare main method as private | rajesh.tripathi | Java | 8 | 10-03-2007 06:49 AM |
| Can void be the return value of main Function | joel | C and C++ | 3 | 09-10-2007 02:21 AM |