1. Home >
  2. Apps >
  3. Groups >

Why makers of Java didn't give the main() function Public and Static as an inbuilt functionality?

Question asked by Aadesh in #Java on Sep 24, 2012
Aadesh
Aadesh · Sep 24, 2012
Rank D3 - MASTER
Interface Methods have inbuilt functionality of being abstract and public (ie we do not neccessarily have to declare them Abstract / Public)
Similiarily Interface Variables are Public, Static and Final!!

Obviously there are certain reasons for this!!

My doubt is why dint the makers of Java give the main() function Public and Static as an inbuilt functionality? I mean main() is the Starting point of program execution and it must be accessible from everywhere , thats why we use static public, i know!!
but Since Everytime we use main(), if it has to be static and public, then why dint they makers of java give it an in-built functionality?? Posted in: #Java
Anoop Kumar
Anoop Kumar · Sep 24, 2012
Rank A2 - PRO
main method is a class member and when program start running JVM looks for standard definition public static void main(String []args) .
if main() would only used for starting point.. then what happen if developer wants to create his/her own method name main().


Basic idea of interface is contract between client and developer that following name of methods will be there and developer will implement by its own
while variable are client chosen which obviously should not be changed that is why static,final.
Aadesh
Aadesh · Sep 25, 2012
Rank D3 - MASTER
is it possible to create more than 1 main() in a java program?
Anoop Kumar
Anoop Kumar · Sep 25, 2012
Rank A2 - PRO
why not try yourself 😀

You must log-in or sign-up to reply to this post.

Click to Log-In or Sign-Up