类实现多个接口
package java51; public interface Useleg { void run(); void walk(); } package java51; public interface Usemouth { void speak(); void eat(); } package java51; public interface Useear { void hearMusic(); } package java51; public interface Useeye { void seeFilm(); } package java51; public class Person implements Useleg, Usemouth, Useear, Useeye{ String name; int age; String adddress; String ID; public void run(){ System.out.println("I am running."); } public void walk(){ System.out.println("I am walking."); } public void speak(){ System.out.println("I am speaking."); } public void eat(){ System.out.println("I am eating."); } public void hearMusic(){ System.out.println("I am leistening to music."); } public void seeFilm(){ System.out.println("I am seeing a film."); } } package java51; public class Test { public static void main(String[] args) { // TODO code application logic here Person p = new Person(); p.seeFilm(); } }
时间: 2024-11-06 13:10:47