CrazyEngineers
  • Reason behind calling a constructor in main function wich a static method..

    Amanneo

    Member

    Updated: Oct 27, 2024
    Views: 1.2K
    if constructor is a instance method then how it gets called in a static context which is a main method.....how is it possible????? i have a lot of confusion about this topic...i am not getting rid of this confudion....can nyone help me out????
    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
  • micheal john

    MemberJun 7, 2015

    #-Link-Snipped-# Can you elaborate you question with an example
    Are you sure? This action cannot be undone.
    Cancel
  • Phenomenal

    MemberJun 8, 2015

    A constructor is defined and not called when you run the program (i.e main method gets called).
    A constructor is called only when you create an object of a class.
    I'll brush up on my basics and provide you a proper answer here in a bit.
    Are you sure? This action cannot be undone.
    Cancel
  • Shashank Moghe

    MemberJun 9, 2015

    The constructor is "invoked" and not explicitly called when an object is created. I believe that is the only reason a static function, Main(), can allow an implicit call to the constructor.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register