public interface Working {
public void work();
}
When you create a class that uses an interface, you reference the interface with the reserved word implements Interface_list. Interface_list is one or more interfaces as multiple interfaces are allowed. Any class that implements an interface must include code for all methods in the interface. This ensures commonality between interfaced objects.
public class WorkingMan extends Man implements Working {
public WorkingMan(String name) {
super(name);
}
public void work(){
speak();
System.out.println("interface implemented");
}
}
No comments:
Post a Comment