Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    May 2016
    Posts
    26

    What is the difference between super() and this()?


  2. #2
    Registered User
    Join Date
    Mar 2019
    Location
    Ahmedabad
    Posts
    10
    super() as well as this() both are used to make constructor calls.
    super() is used to call Base class's constructor(i.e, Parent's class) while this() is used to call current class's constructor.
    If you use this() and super() together in a constructor it will give compile time error.

  3. #3
    Senior Member
    Join Date
    Apr 2019
    Location
    Asia
    Posts
    110
    super() as well as this() both are used to make constructor calls.
    super() is used to call Base class's constructor(i.e, Parent's class) while this() is used to call current class's constructor.
    super() is used to call Base class's(Parent class's) constructor.
    Anika Bhardwaj - ServersBase.Com
    Solutions Tailored To Your Requirements For Unbeatable Agility.
    100% Uptime Guarantee Fully Manged Servers
    SSD Disk Hosting Cloudlinux OS LightSpeed

  4. #4
    Senior Member
    Join Date
    Jul 2017
    Location
    Bangalore
    Posts
    210
    As Hence super must be first statement in a constructor. Java enforces that the call to super (explicit or not) must be the first statement in the constructor. This is to prevent the subclass part of the object being initialized prior to the superclass part of the object being initialized.

  5. #5

  6. #6
    Registered User
    Join Date
    Feb 2019
    Posts
    773
    super() and this() in java. super() as well as this() both are used to make constructor calls. super() is used to call Base class's constructor(i.e, Parent's class) while this() is used to call current class's constructor. super() is use to call Base class's(Parent class's) constructor.

Tags for this Thread

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.