0

Following is the code I encountered during execution of Kinesis Streams

Class XYZ implements ABC {
       XYZ(){
        super();
     }
    }

What is the use of super in this case ?

2 Answers2

1

super is used to invoke the constructor, methods and attributes of the parent class. In this case super will invoke the constructor of Object class, which by default in Java is super class of all classes. hence, super is redundant in this case.

yogidilip
  • 790
  • 6
  • 21
  • I am not sure you are right. that is depend if the interface contains default implementation. – Rotem Nov 29 '16 at 20:06
0

The use of super() in the subclass means invoking the super class constructor. In case that the Class XYZ implements an interface, there is no meaning for the constructor invocation, cause the interface usually does not contain implementation. I know that since Java 8 there is the ability to add default implementation to an interface. When the interface contains the default keyword before a method or a constructor that means default implementation for the related method or constructor.

You can read more about Interface Method Declarations.

Rotem
  • 1,381
  • 1
  • 11
  • 23