Interface
All interface classes are by default Public
and Abstract
, and do not contain any completed methods.
Interface should implement (complete the body of a method) when all the abstract methods are inherited from the superclass (abstract class).
The actual use of interface will be structuring (setting or mandating to set off rules).
An example of a Java program with an interface
The following is an example of an interface in a Java program:
package MyFirstPackage; interface sample_abs2 { void abstr_method (); void abstr_method1(); } abstract class sample_abs3 implements sample_abs2 { abstract void abstr_method2 (); void abstr_method2A(){ System.out.println("Abstact class abstr_method2A"); } } class Interface extends sample_abs3 {//implements is a keyword used to complete the //Interface Class public void abstr_method () { System.out.println("Interface abstr_method implementation"); } public void abstr_method1 () { System.out.println...