📄 testmix.java
字号:
package Inheritance;
/*
* 继承与实现的混合
*/
interface Flyer {
void takeOff();
void land();
void fly();
}
interface Magic{
void change();
}
//接口可以继承多个接口
interface FlyerMagic extends Flyer,Magic{
}
class Airplane implements Flyer{
public void fly() {
System.out.println("The airplane is flying.");
}
public void land() {
System.out.println("The airplane is landing.");
}
public void takeOff() {
System.out.println("The airplane is taking off.");
}
}
abstract class Animal{
abstract void eat();
}
class Superman extends Animal implements Flyer,Magic{
public void fly() {
System.out.println("The superman is flying.");
}
public void land() {
System.out.println("The superman is landing.");
}
public void takeOff() {
System.out.println("The superman is taking off.");
}
public void eat(){
System.out.println("The superman is eating.");
}
public void change() {
System.out.println("The superman is changing.");
}
}
public class TestMix {
public static void main(String[] args) {
Superman s=new Superman();
s.eat();
s.fly();
s.land();
s.takeOff();
s.change();
Airplane a=new Airplane();
a.fly();
a.land();
a.takeOff();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -