GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 451 of 493    Print  
Every application should have a main() method. Under which class does the main() method comes under?

  
Total Answers and Comments: 5 Last Update: November 04, 2008     Asked by: maharamesh87 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
November 26, 2007 06:15:23   #1  
shivkant.pawan Member Since: November 2007   Contribution: 5    

RE: Every application should have a main() method. Und...
You should have to put the main() method in public class.
 
Is this answer useful? Yes | No
November 29, 2007 12:01:48   #2  
GSSSGopinath Member Since: November 2007   Contribution: 1    

RE: Every application should have a main() method. Under which class does the main() method comes under?
It may not required to put the main method in the public class. But we have to save the file with the public class name. So, it is preferrable to put the main() method in the public class. Other wise we need to remember in which class you put the main method and need to give that class name while running.
 
Is this answer useful? Yes | No
June 09, 2008 04:40:43   #3  
kiranmai.kasturi Member Since: June 2008   Contribution: 4    

RE: Every application should have a main() method. Under which class does the main() method comes under?
put main method in any class but that class should have public access specifier if you want to execute that method.
 
Is this answer useful? Yes | No
November 03, 2008 06:46:26   #4  
hari.krishna709 Member Since: October 2008   Contribution: 4    

RE: Every application should have a main() method. Under which class does the main() method comes under?
Even if you dont have main method we can develop program like
    public class{
 static
  {
   System.out.println("Hello world");
  System.exit(0);
  }
}
this will execute without errors

 
Is this answer useful? Yes | No
November 04, 2008 02:12:19   #5  
vawani Member Since: July 2006   Contribution: 3    

RE: Every application should have a main() method. Under which class does the main() method comes under?
If you  are writing a program in java then you have to put main method in a class, so  that class is the owner of main method but since  we r declaring it as public it is available to all class ,and also you have to use the modifier STATIC so the JVM can access the method without creating the class object of that class.



regards
MR vawani

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape