网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

publicclassEmployee{privateStringname;publicEmployee(Stringname){this.name=name;}publicStringgetName(){returnname;}}publicclassManagerextendsEmployee{privateStringdepartment;publicManager(Stringname,Stringdepartment){this.department=department;super(name);(应于上一行掉位置)System.out.println(getName());}}Super的位置是否在方法的首行执行语句newManager(smith”,”SALES”)后程序的输出是哪项?()

A.smith

B.null

C.SALES

D.编译错误


参考答案

更多 “ publicclassEmployee{privateStringname;publicEmployee(Stringname){this.name=name;}publicStringgetName(){returnname;}}publicclassManagerextendsEmployee{privateStringdepartment;publicManager(Stringname,Stringdepartment){this.department=department;super(name);(应于上一行掉位置)System.out.println(getName());}}Super的位置是否在方法的首行执行语句newManager(smith”,”SALES”)后程序的输出是哪项?()A.smithB.nullC.SALESD.编译错误 ” 相关考题
考题 publicclassEmployee{privateStringname;publicEmployee(Stringname){this.name=name;}publicvoiddisplay(){System.out.print(name);}}publicclassManagerextendsEmployee{privateStringdepartment;publicManager(Stringname,Stringdepartment){super(name);this.department=department;}publicvoiddisplay(){System.out.println(super.display()+”,”+department);}}执行语句newManager(smith”,”SALES”)后程序的输出是哪项?()A.smith,SALESB.null,SALESC.smith,nullD.null,null

考题 类Teacher:classTeacher{Stringname;floatsalary;Teacher(Stringname){this.name=name;}Teacher(Stringname,floatsalary){this.name=name;this.salary=salary;}}执行语句Teachert=newTeacher(Tom”,2000.0f);后,字段salary的值是哪一项?()A.2000.0fB.0.0fC.null;D.2000

考题 publicclassPet{privateStringname;publicPet(Stringname){this.name=name;}publicvoidspeak(){System.out.print(name);}}publicclassDogextendsPet{publicDog(Stringname){super(name);}publicvoidspeak(){super.speak();System.out.print(Dog”);}}执行代码Petpet=newDog(京巴”);pet.speak();后输出的内容是哪项?()A.京巴B.京巴DogC.nullD.Dog京巴

考题 publicclassPerson{2.privateStringname;3.publicPerson(Stringname){this.name=name;}4.publicbooleanequals(Personp){5.returnp.name.equals(this.name);6.}7.}Whichistrue?() A.TheequalsmethoddoesNOTproperlyoverridetheObject.equalsmethod.B.Compilationfailsbecausetheprivateattributep.namecannotbeaccessedinline5.C.Toworkcorrectlywithhash-baseddatastructures,thisclassmustalsoimplementthehashCodemethod.D.WhenaddingPersonobjectstoajava.util.Setcollection,theequalsmethodinline4willpreventduplicates.

考题 publicclassPlant{privateStringname;publicPlant(Stringname){this.name=name;}publicStringgetName(){returnname;}}publicclassTreeextendsPlant{publicvoidgrowFruit(){}publicvoiddropLeaves(){}}Whichistrue?() A.Thecodewillcompilewithoutchanges.B.ThecodewillcompileifpublicTree(){Plant();}isaddedtotheTreeclass.C.ThecodewillcompileifpublicPlant(){Tree();}isaddedtothePlantclass.D.ThecodewillcompileifpublicPlant(){this(”fern”);}isaddedtothePlantclass.E.ThecodewillcompileifpublicPlant(){Plant(”fern”);}isaddedtothePlantclass.

考题 interface Playable {void play();}interface Bounceable {void play();}interface Rollable extends Playable, Bounceable {Ball ball = new Ball("PingPang");}class Ball implements Rollable {private String name;public String getName() {return name;}public Ball(String name) {this.name = name;}public void play() {ball = new Ball("Football");System.out.println(ball.getName());}}这个错误不容易发现。

考题 Person p = new Person(“张三”,23);这条语句会调用下列哪个构造方法给属性进行初始化() A.public Person(){}B.public Person(String name,int age) { this.name = name; this.age = age; }C.public Person(int age,String name) { this.age = age; this.name = name; }D.public Person(String name) { this.name = name; }

考题 23、下列程序的运行结果是【 】 class Demo{ private String name; Demo(String name){this.name = name;} private static void show(){ System.out.println(name) } public static void main(String[] args){ Demo d = new Demo(“lisa”); d.show(); } }A.输出lisaB.输出nullC.输出nameD.编译失败,无法从静态上下文中引用非静态变量name

考题 3、下列程序的运行结果是【 】 class Demo{ private String name; Demo(String name){this.name = name;} private static void show(){ System.out.println(name) } public static void main(String[] args){ Demo d = new Demo(“lisa”); d.show(); } }A.输出lisaB.输出nullC.输出nameD.编译失败,无法从静态上下文中引用非静态变量name