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

    Aadesh

    Member

    Updated: Oct 27, 2024
    Views: 1.1K
    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??
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Anoop Kumar

    MemberSep 24, 2012

    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.
    Are you sure? This action cannot be undone.
    Cancel
  • Aadesh

    MemberSep 25, 2012

    is it possible to create more than 1 main() in a java program?
    Are you sure? This action cannot be undone.
    Cancel
  • Anoop Kumar

    MemberSep 25, 2012

    why not try yourself 😀
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register