Geeks Talk

Prepare for your Next Interview




return type of main method

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[])...


Go Back   Geeks Talk > Software Development > Java

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 08-27-2008
Junior Member
 
Join Date: Aug 2008
Location: Delhi
Posts: 9
Thanks: 5
Thanked 0 Times in 0 Posts
Shwet_45 is on a distinguished road
return type of main method

Can we use 'int' as return type of main method in java??
like:
public static int main(String args[])
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-27-2008
Junior Member
 
Join Date: Apr 2008
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
mamatha.cute is on a distinguished road
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
Reply With Quote
The Following User Says Thank You to mamatha.cute For This Useful Post:
  #3 (permalink)  
Old 08-27-2008
Junior Member
 
Join Date: Aug 2008
Location: madurai
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
kunal066 is on a distinguished road
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)
Reply With Quote
The Following User Says Thank You to kunal066 For This Useful Post:
  #4 (permalink)  
Old 09-05-2008
Junior Member
 
Join Date: Jun 2007
Location: India
Posts: 20
Thanks: 0
Thanked 6 Times in 4 Posts
deeptiagrawal is on a distinguished road
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.
Reply With Quote
The Following User Says Thank You to deeptiagrawal For This Useful Post:
  #5 (permalink)  
Old 09-10-2008
Junior Member
 
Join Date: Sep 2008
Location: chennai
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
PRINCEJOHNWESLEY is on a distinguished road
Lightbulb Re: return type of main method

Quote:
Originally Posted by Shwet_45 View Post
Can we use 'int' as return type of main method in java??
like:
public static int main(String args[])
No.
Two valid signature of main methods:
public static void main(String[] prince)
or
static public void main(String[] prince)
Reply With Quote
The Following User Says Thank You to PRINCEJOHNWESLEY For This Useful Post:
Reply

  Geeks Talk > Software Development > Java


Thread Tools
Display Modes


Similar Threads

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


All times are GMT -4. The time now is 11:48 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved