Skip to main content

whenWhen you inherit from Super this is what in reality happens:

public class Son extends Super{

  // If you dont declare a constructor of any type, adefault one will appear.
  public Son(){
    // If you dont call any other constructor in the first line a call to super() will be placed instead.
    super();
  }

}

So, that is the reason cause, because you have to call to your unique constructor, cause "Super" doesntsince"Super" doesn't have a default one.

Now, trying to guess why Java doesn't support constructor inheritance, probably causebecause a constructor only havemakes sense if it's talking about concrete instances, and you shouldn't be able to create an instance of something thatwhen you don't know how isit's defined (by polymorphism).

when you inherit from Super this is what in reality happens:

public class Son extends Super{

  // If you dont declare a constructor of any type, adefault one will appear.
  public Son(){
    // If you dont call any other constructor in the first line a call to super() will be placed instead.
    super();
  }

}

So, that is the reason cause you have to call to your unique constructor, cause "Super" doesnt have a default one.

Now, trying to guess why Java doesn't support constructor inheritance, probably cause a constructor only have sense talking about concrete instances, and you shouldn't be able to create an instance of something that you don't know how is defined (by polymorphism).

When you inherit from Super this is what in reality happens:

public class Son extends Super{

  // If you dont declare a constructor of any type, adefault one will appear.
  public Son(){
    // If you dont call any other constructor in the first line a call to super() will be placed instead.
    super();
  }

}

So, that is the reason, because you have to call your unique constructor, since"Super" doesn't have a default one.

Now, trying to guess why Java doesn't support constructor inheritance, probably because a constructor only makes sense if it's talking about concrete instances, and you shouldn't be able to create an instance of something when you don't know how it's defined (by polymorphism).

added 268 characters in body
Source Link
David Santamaria
  • 8.8k
  • 8
  • 36
  • 43

when you inherit from Super this is what in reality happens:

public class Son extends Super{

  // If you dont declare a constructor of any type, adefault one will appear.
  public Son(){
    // If you dont call any other constructor in the first line a call to super() will be placed instead.
    super();
  }

}

So, that is the reason cause you have to call to your unique constructor, cause "Super" doesnt have a default one.

Now, trying to guess why Java doesn't support constructor inheritance, probably cause a constructor only have sense talking about concrete instances, and you shouldn't be able to create an instance of something that you don't know how is defined (by polymorphism).

when you inherit from Super this is what in reality happens:

public class Son extends Super{

  // If you dont declare a constructor of any type, adefault one will appear.
  public Son(){
    // If you dont call any other constructor in the first line a call to super() will be placed instead.
    super();
  }

}

So, that is the reason cause you have to call to your unique constructor, cause "Super" doesnt have a default one.

when you inherit from Super this is what in reality happens:

public class Son extends Super{

  // If you dont declare a constructor of any type, adefault one will appear.
  public Son(){
    // If you dont call any other constructor in the first line a call to super() will be placed instead.
    super();
  }

}

So, that is the reason cause you have to call to your unique constructor, cause "Super" doesnt have a default one.

Now, trying to guess why Java doesn't support constructor inheritance, probably cause a constructor only have sense talking about concrete instances, and you shouldn't be able to create an instance of something that you don't know how is defined (by polymorphism).

Post Undeleted by David Santamaria
Post Deleted by David Santamaria
Source Link
David Santamaria
  • 8.8k
  • 8
  • 36
  • 43

when you inherit from Super this is what in reality happens:

public class Son extends Super{

  // If you dont declare a constructor of any type, adefault one will appear.
  public Son(){
    // If you dont call any other constructor in the first line a call to super() will be placed instead.
    super();
  }

}

So, that is the reason cause you have to call to your unique constructor, cause "Super" doesnt have a default one.