Interface in Java: Java interfaces are like Java classes but they contain only static final constants and declaration of methods. Methods are not defined and classes which implements an interface must define the body of method(s) of interface(s). Final constants can't be modified once they are initialized; final, interface, extend and implements are Java keywords.
Declaration of interface:
Interface program in Java
In our program we create an interface named Info which contains a constant and a method declaration. We create a class which implements this interface by defining the method declared inside it.
Download Interface program class file.
Output of program:
No comments:
Post a Comment