Object creation of interface in Java | Core Java Tutorials

This Core Java Tutorials”Object creation of interface in Java” is providing information about why we cannot instantiate interface in java application.


 

Can we define constructor inside interface?

  • Interface doesn’t allow non static concrete methods.
  • Constructor is non static method.
  • Hence we cannot define constructor.
  • Without constructor, instantiation is not possible.

 

  • Class can be instantiated in 2 ways. Directly using ‘new’ keyword and through ‘Child’ class.
  • Abstract class can in instantiated only through ‘Child-class’.
  • Interface cannot be instantiated either directly or in-directly.

Instantiation of Interface in Java

 

Share this