Declaring Interfaces in Java

In order to declare an interface, you must use the interface keyword. Here is a straightforward illustration that can be used for declaring an interface. The standard structure and order of statements that can be used for this purpose are as follows:

import java.lang.*;
public interface Interfacename {
//Statements}

Interfaces have the accompanying properties:

  • An interface is verifiably dynamic. You don’t have to utilize the keyword abstract when declaring an interface.
  • Each method in an interface is additionally dynamic, so the keyword abstract is not required.
  • Methods in an interface are certainly public.

Sample Implementation

interface MyAnimal {

public void eatinghabits();

public void walkinghabits();

}


 

For any query or issue, feel free to discuss on http://discuss.eduguru.in