题目内容

编译并运行以下程序,以下描述哪个选项是正确的()1.classX{2.protectedStringtoString(){3.returnsuper.toString();}4.}

A. 编译通过运行无异常
B. 编译通过但运行时出错
C. 行2出错,不能成功编译
D. 不能成功编译,行3出错

查看答案
更多问题

类Parent、Child定义如下:public class Parent{public float aFun(float a, float b) throws IOException {}}public class Child extends Parent{//第6行}将以下哪种方法插入行6是不合法的

A. float aFun(float a, float b){ }
B. public int aFun(int a, int b)throws Exception{ }
C. public float aFun(float p, float q){ }
D. public int aFun(int a, int b)throws IOException{ }

子类对父类继承来的属性重新定义称为____。子类对自身拥有的同名方法的重新定义称____。(每空两个字)

创建一个名为mypackage的包的语句是____。

以下程序段的输出结果为(注意空格)publicclassFather{Stringname,address,tel;intage;publicFather(Stringname,intage){this.name=name;this.age=age;}voidout(){System.out.print("姓名:"+name);System.out.print("年龄:"+age);}voidoutOther(){System.out.print("家庭住址:"+address);System.out.print("电话:"+tel);}publicstaticvoidmain(Stringargs[]){Sonson=newSon("Tom",15);son.address="金水区";son.school="九中";son.tel="66123456";son.out();}}classSonextendsFather{Stringschool;publicSon(Stringname,intage){super(name,age);}voidout(){super.out();super.outOther();System.out.println("学校:"+school);}}

答案查题题库