0

i want to call super class constructor in sub class construtor. For that i am using super() but without super() also, i can able to call super class constructor. how it works.

  1. Example: here i am using super() enter image description here

2.Example: here i am not using super(), but it works fine

enter image description here

Karthick A.S
  • 177
  • 1
  • 13
  • how it called the parent class constructor without super()......any idea? – Karthick A.S May 07 '16 at 08:35
  • 3
    see the already existing question and answer. Also it is recommended to include code as text and not screenshots... – wero May 07 '16 at 08:40
  • possible duplicate of [this](http://stackoverflow.com/questions/10508107/why-call-super-in-a-constructor) – lazary May 07 '16 at 08:41
  • ok...It may be duplicate,But I need to know why the parent class constructor called without super() ? – Karthick A.S May 07 '16 at 08:44
  • @KarthickA.S It is called because the [Java Language Specification (section 8.8.7)](http://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.8.7) says so (_"If a constructor body does not begin with an explicit constructor invocation and the constructor being declared is not part of the primordial class Object, then the constructor body implicitly begins with a superclass constructor invocation "super();", an invocation of the constructor of its direct superclass that takes no arguments."_) – Mark Rotteveel May 07 '16 at 09:30

0 Answers0