明天要考试了,有一道关于java的编程题想请大家帮帮忙啊 ,急!谢谢了

2024-11-07 22:48:57
有2个网友回答
网友(1):

package MainPackage;

class ParentClass {
String s = "this is ParentClass!";
public ParentClass(){
System.out.println(s);
}
}
class SubClass extends ParentClass{

public SubClass(){
super.s = "this is SubClass!";
System.out.println(s);
}
}
import MainPackage.ParentClass;

public class DemoPackage {

public static void main(String[] args) {
SubClass sub = new SubClass();

}

}

网友(2):

我总结一下,一楼正解。