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 311 of 483    Print  
Can we override the main method?

  
Total Answers and Comments: 46 Last Update: July 01, 2008     Asked by: diensh 
  
 Sponsored Links



 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
  Sorting Options  
  Page 1 of 5   « First    1    2    3    >     Last »  
September 22, 2006 04:07:22   #1  
Samkit Jain        

RE: Can we override the main method?
No ,u cannot have two main methods in the same package
 
Is this answer useful? Yes | No
September 27, 2006 03:09:55   #2  
esrinivas        

RE: Can we override the main method?

  there is no two main methods in the same class,but we can have two main methods in  same package


 
Is this answer useful? Yes | No
September 27, 2006 05:56:26   #3  
srikanth        

RE: Can we override the main method?
NO, we cannot override main menthod as JVM will not know which main method to be executed first.
 
Is this answer useful? Yes | No
October 01, 2006 14:29:04   #4  
Ramesh        

RE: Can we override the main method?
We can override the main method .at the same time we can also overload the main method. i am sure i execute it
 
Is this answer useful? Yes | No
October 02, 2006 14:10:47   #5  
prashamsa        

RE: Can we override the main method?

please ramesh can u elobrate that..with an example


 
Is this answer useful? Yes | No
October 03, 2006 03:57:15   #6  
Shankar        

RE: Can we override the main method?
Hi ,You have rights to overload main(),but jvm can invoke only main with String[] s. not other arguments main.If u come for override both sub class and super class can hold its own main. any way we can't invoke main with help of either object ref or super. but at compile time we can't get any error suppose both super and sub has main.
 
Is this answer useful? Yes | No
October 03, 2006 04:01:45   #7  
Shankar        

RE: Can we override the main method?

Hi,

Java allow main() to overload, but yvm invoke which is having String[]s asrguments.Ex.


 
Is this answer useful? Yes | No
October 03, 2006 07:58:21   #8  
Sindhu        

RE: Can we override the main method?
cld u plz justify..
 
Is this answer useful? Yes | No
October 03, 2006 10:42:03   #9  
ashish_setia Member Since: October 2006   Contribution: 15    

RE: Can we override the main method?
yes , we can overload and override the main method. and i t will work u can try this.
 
Is this answer useful? Yes | No
October 03, 2006 13:12:11   #10  
ashish_setia Member Since: October 2006   Contribution: 15    

RE: Can we override the main method?

check out this example

class Checkmain{
public static void main(String args[]){
args[1]="ashish";
System.out.println("hello ");
}
}
class Checkmain1 extends Checkmain{
public static void main(String args[]){
System.out.println("how r u");
}

}
class Jo{
public static void main(String args[]){
String S[]=new String[10] ;

Checkmain.main(S);
Checkmain1.main(S);
}}


 
Is this answer useful? Yes | No
  Page 1 of 5   « First    1    2    3    >     Last »  


 
Go To Top


 Sponsored Links



 
Sponsored Links

 
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