1

您如何定义类/接口 Adult、Student 和 Engineer,以便下一个序列仅在指定的地方给出编译错误?

class Test {
public static void main(String args[]) {
Adult a = new Student(); //without giving compilation error
Adult b = new Engineer();//without giving compilation error
a.explorare(); //without giving compilation error
b.explorare(); //without giving compilation error
a.afisare(); //without giving compilation error
b.afisare(); //compilation error
4

1 回答 1

1

这是不可能的,如果a.afisare()编译那么应该b.afisare()

于 2012-11-17T00:53:50.917 回答