设计一个有关Java 借口的类(大家帮帮忙啊!在线等……)

来源:百度知道 编辑:UC知道 时间:2024/07/02 18:30:33
有两个接口A和B,其形式如下:
interface A{void f1();int f2();}
interface B{char b='b';String s="abc";
void f3();char f4();int f5(String s);}
设计一个类C(class)实现接口A和接口B

interface A {
void f1();

int f2();
}

interface B {
char b = 'b';

String s = "abc";

void f3();

char f4();

int f5(String s);
}

public class C implements A, B {
public static void main(String[] args) {
C c = new aaa();
c.f1();
c.f2();
c.f3();
c.f4();
c.f5(s);
}

public void f1() {
System.out.println("我是接口A的方法f1!");

}

public int f2() {
System.out.println("我是接口A的方法f2!");
return 0;
}

public void f3() {
System.out.println("我是接口B的方法f3!");

}

public char f4() {
System.out.println(b);
return 0;
}

public int f5(String s) {
System.out.println(s);
return 0;
}

}

你为什么不创建一个类,在接口里添加上这些接口 不就自己生成了?
class C implements A,B{