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
    19
    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
    135
    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.
    ServersBase.Com- sales@serversbase.com
    █ SSD cPanel Web Hosting LiteSpeed MariaDB CloudLinux & MultiPHP!
    Solutions Tailored To Your Requirements For Unbeatable Agility.
    █ Fully Managed Cloud Instances, Daily Backups & Active Monitoring!

  4. #4
    Senior Member
    Join Date
    Jul 2017
    Location
    Bangalore
    Posts
    226
    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
    1,541
    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.