Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    8

    Is it possible to override constructors in Java?

    can we override constructors?

  2. #2
    Registered User
    Join Date
    Oct 2011
    Posts
    770
    No, you can't override a constructor. They're not inherited. However, each subclass constructor has to chain either to another constructor within the subclass or to a constructor in the superclass.
    Asia Affordable Web Hosting Provider

  3. #3
    Senior Member
    Join Date
    Apr 2008
    Location
    USA
    Posts
    535
    Constructor is a method which have same name as class name and no return value.

    Overriding means what we have declared in Super class, that exactly we have to declare in Sub class it is called Overriding. Super class name and Sub class names are different.

    So as We can not declare same class(with same constructors) twice in same program, hence we can not Override Constructor.
    AccuWebHosting.Com | ASP.Net Hosting Provider Since 2003
    Cloud Powered Hosting | Windows VPS | Dedicated Servers
    US Based Hosting Company | Trusted by 20,000+ Clients Worldwide

  4. #4
    Senior Member
    Join Date
    Feb 2022
    Posts
    148
    No we cannot override the constructor. A constructor is a special member function of class with the same name as that of class. Its primary purpose is to initialize the data members of the instance of the class. Hence saying that it initializes the data members of the class would be wrong.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

  Find Web Hosting      
  Shared Web Hosting UNIX & Linux Web Hosting Windows Web Hosting Adult Web Hosting
  ASP ASP.NET Web Hosting Reseller Web Hosting VPS Web Hosting Managed Web Hosting
  Cloud Web Hosting Dedicated Server E-commerce Web Hosting Cheap Web Hosting


Premium Partners:


Visit forums.thewebhostbiz.com: to discuss the web hosting business, buy and sell websites and domain names, and discuss current web hosting tools and software.