·  JAVA – Syntax – Keywords – interface, implements


- Info:

  - interface declares constants and method declarations, but not method implementations.

    Java interfaces are meant to replace multiple inheritance.

  - implements defines that class must implements functions from given list of interfaces.

  - To instantiate a class that implements interface, that class has to give body to all functions from interface.

  - This ensures that all classes that implement the same interface have the same set of functions (interface).


- Procedure:

  - Create JAVA Console Application Test.java



    public class Test{ 

      public static void main(String[] args) {  

        Instrument instrument = new Instrument();





    interface SoundInterface {

      public int  i=10;

      public void sound();



    interface GravityInterface {

      public double g = 9.81;

      public void   fall();



    class Instrument implements SoundInterface, GravityInterface {

      public void sound() { System.out.println("Playing note"        ); };

      public void fall () { System.out.println("Falling from the sky"); };