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

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

publicclassPet{privateStringname;publicPet(){System.out.print(1);}publicPet(Stringname){System.out.print(2);}}publicclassDogextendsPet{publicDog(){System.out.print(4);}publicDog(Stringname){super(name);System.out.print(3);}}执行newDog(棕熊”);后程序输出是哪项?()

A.33

B.13

C.23

D.123


参考答案

更多 “ publicclassPet{privateStringname;publicPet(){System.out.print(1);}publicPet(Stringname){System.out.print(2);}}publicclassDogextendsPet{publicDog(){System.out.print(4);}publicDog(Stringname){super(name);System.out.print(3);}}执行newDog(棕熊”);后程序输出是哪项?()A.33B.13C.23D.123 ” 相关考题
考题 如下程序的输出结果是______。 include using namespace std; class Pet{ char nam 如下程序的输出结果是______。include<iostream>using namespace std;class Pet{char name[10];public:Pet(char*nanle){strcpy(this->name,name);}const char*getName( )const{return name;}virtual void call( )eonst=0;};class Dog:public Pet{public:Dog(char*name):Pet(name){ }void call( )eonst{cout<<"汪汪叫";}};class Cat:public Pet{public:Cat(char*name):Pet(name){ }void call( )const{eout<<"喵喵叫";}};int main( ){Pet*petl=new Dog("哈克"),*pet2=new Cat("吉米");eout<<petl->getName( );petl->call( );eout<<endl;cout<<pet2->getName( );pet2->call( );eout<<endl;return 0;}

考题 publicclassPet{publicvoidspeak(){System.out.print(Pet”);}}publicclassCatextendsPet{publicvoidspeak(){System.out.print(Cat”);}}publicclassDogextendsPet{publicvoidspeak(){System.out.print(Dog”);}}执行代码Pet[]p={newCat(),newDog(),newPet()};for(inti=0;i〈p.length;i++)p[i].speak();后输出的内容是哪项?()A.PetPetPetB.CatCatCatC.CatDogPetD.CatDogDog

考题 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

考题 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.编译错误

考题 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京巴

考题 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.

考题 有如下程序: include using namespace std; class Pet{ char name[10]; public: Pet(c 有如下程序:include<iostream>using namespace std;class Pet{char name[10];public:Pet(char*name){strcpy(this->name,name);}const char*getName()const {return name;}virtual void call()const=0;};class Dog:public Pet{public:Dog(char*name):Pet(name){}void call()const{cout<<"汪汪叫":}};class Cat:public Pet{public:Cat(char*name):Pet(name){}void call()const{cout<<"喵喵叫";}};int main(){Pet*pet1=new Dog("哈克"),*pet2=new Cat("吉米");cout<<pet1->getName();pet1->call();cout<<end1;cout<<pet2->getName();pet2->call();cout<<end1;return 0;}程序的输出结果是______。

考题 Java代码查错1.abstract class Name {private String name;public abstract boolean isStupidName(String name) {}}大侠们,这有何错误?

考题 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());}}这个错误不容易发现。