首页 > 试题广场 >

阅读以下程序,写出输出结果。

[问答题]

阅读以下程序,写出输出结果。

public class Class3 {
public static void main(String args[]) {
SubSubClass x = new SubSubClass(10, 20, 30);
x.show();
}
}
 
class SuperClass {
int a, b;
 
SuperClass(int aa, int bb) {
a = aa;
b = bb;
}
 
void show() {
System.out.println("a=" + a + "\nb=" + b);
}
}
 
class SubClass extends SuperClass {
int c;
 
SubClass(int aa, int bb, int cc) {
super(aa, bb);
c = cc;
}
}
 
class SubSubClass extends SubClass {
int a;
 
SubSubClass(int aa, int bb, int cc) {
super(aa, bb, cc);
a = aa + bb + cc;
}
 
void show() {
System.out.println("a=" + a + "\nb=" + b + "\nc=" + c);
}
}

a=60

b=20

c=30

发表于 2017-05-17 16:37:55 回复(0)