11.写出程序结果
[java] view plaincopy
class Fu
{
int num=4;
void show()
{
System.out.println("showFu");
}
}
class Zi extends Fu
{
int num=5;
void show()
{
System.out.println("showZi");
}
}
class T
{
public static void main(String[] args)
{
Fu f=new Zi();
Zi z=new Zi();
System.out.println(f.num);
System.out.println(z.num);
f.show();
z.show();
}
}
结果是: 4
5
showZi
showZi
12.补足代码
[java] view plaincopy
interface A
{
void show();
}
interface B
{
void add(int a,int b)
}
class C implements A,B
{
private int a,b;
public void add(int a,int b)
{
this.a=a;
this.b=b;
}
public void show()
{
System.out.println(a+b);
}
}
class D
{
public static void main(String[] args)
{
C c=new C();
c.add(4,2);
c.show();//通过该函数打印以上两个数的和。
}
}