• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

very basic question which most of us donot know

 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a very coomon question asked in many interviews
we use public static void main (String abc[]) as signature of first executing method
in our class but
all these variations in this signature also run very smoothly
static void main(String abc[])
private static void main(String abc[])
protected static void main(String abc[])
can any one pls tell then what is the diff if all methodsrun in same way
 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gaurav Chikara:
This is a very coomon question asked in many interviews
we use public static void main (String abc[]) as signature of first executing method in our class but all these variations in this signature also run very smoothly
static void main(String abc[])
private static void main(String abc[])
protected static void main(String abc[])
can any one pls tell then what is the diff if all methods run in same way


Hi Gaurav,
main method is required to be static only, access modifier is not an issue. It will compile and run with any access modifier. (because runtime does allow private to be called, and main is called by runtime). This has been logged as a bug with Sun, but they don't think it's an important bug
Have a look at - http://developer.java.sun.com/developer/bugParade/bugs/4252539.html
HTH,
- Manish
[This message has been edited by Manish Hatwalne (edited October 18, 2001).]
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
You can also declare the main method as being final without any detrimental consequences.
------------------
"One good thing about music - when it hits, you feel no pain"
Bob Marley
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic