网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
publicclassParent{intchange(){…}}classChildextendsParent{}WhichmethodscanbeaddedintoclassChild?()
A.publicintchange(){}
B.intchang(inti){}
C.privateintchange(){}
D.abstractintchang(){}
参考答案
更多 “ publicclassParent{intchange(){…}}classChildextendsParent{}WhichmethodscanbeaddedintoclassChild?() A.publicintchange(){}B.intchang(inti){}C.privateintchange(){}D.abstractintchang(){} ” 相关考题
考题
下列选项中的 方法可以正确地加入类Child中,且父类的方法不会被覆盖。 public class Parent{ public int addValue(int a,int b){ int s; s=a+b; return s; } } class Child extends Parent{ }A.int addValue(int a,int b){∥do something…}B.public void addValue( ){∥do something…}C.public int addValue(int a,int b)throws MyException{∥do something…}D.public float addValue(int a,int b,float b=1.0){∥do something…}
考题
有如下程序段: public class Parent { public int addValue (int a,intB){ int s; s=a+b; return 3; } } class Child extends Parent {} 则下列选项中,可以正确加入类Child中且父类的方法不会被覆盖的是( )。A.int addValue (int a,intB){//do something...}B.public void addValue() {//do something...}C.public int addValue (int a,intB)throws MyException {//do something...}D.public float addValue (int a,int b,float b=1.0) {//do someting...}
考题
下面程序是关于类的继承的用法。阅读下面程序,根据程序中的注释在每一条横线处填写一个语句,使程序的功能完整,且运行程序后的输出结果为:I am parentclass!I am childclass!I am childclass!注意: 请勿改动main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。class Parent {void printMe() {System.out.println("I am parentclass!");}}class Child extends Parent {void printMe() {System.out.println("I am childclass!");}void printAll() {______________.printMe ( ); // 调用父类的方法______________. printMe ( ); //调用本类的方法printMe ( );}}public class TestJieCheng {public static void main(String args[]) {______________myC.printAll();}}
考题
publicclassParent{publicvoidchange(intx){}}publicclassChildextendsParent{//覆盖父类change方法}下列哪个声明是正确的覆盖了父类的change方法?()
A.protectedvoidchange(intx){}B.publicvoidchange(intx,inty){}C.publicvoidchange(Strings){}D.publicvoidchange(intx){}
考题
publicclassParent{publicintaddValue(inta,intb){ints;s=a+b;returns;}}classChildextendsParent{}WhichmethodscanbeaddedintoclassChild?()
A.intaddValue(inta,intb){//dosomething...}B.publicvoidaddValue(){//dosomething...}C.publicintaddValue(inta){//dosomething...}D.publicintaddValue(inta,intb)throwsMyException{//dosomething...}
考题
下列代码的输出结果是( )。class parent{void printme(){System.out.println("parent");}}class child extends parent{void printme(){System. out.println("child");}void printall(){super, printme();this.printme();printme();}}public class test{public static void main(String args[]){child myc=new child();myc.printall();}}A.import java.awt.*;B.import java.applet.applet;C.import java.io.*;D.import java, awt.graphics;
考题
下列可加入类child 中的方法是 public class Parent { protected int change () { } } class Child extends Parent { }A.private int change () { }B.abstract int change () { }C.public int change () { }D.int change () { }
考题
给定如下Java代码,以下()修饰符可以填入下划线处 class Parent{ protected void eat(){} } class Child extends Parent{ ______ void eat(){} }A.finalB.staticC.privateD.public
考题
【多选题】设有如下类的定义: public class parent { int change() {} } class Child extends Parent { } 则,下面哪些方法可加入Child类中?A.public int change(){ }B.int chang(int i){ }C.private int change(){ }D.abstract int chang(){ }
热门标签
最新试卷