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

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

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.PetPetPet

B.CatCatCat

C.CatDogPet

D.CatDogDog


参考答案

更多 “ 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 ” 相关考题
考题 下列程序片段中,能通过编译的是A.public abstract class Animal{ public void speak();}B.public abstract class Animal{ public void speak(){}}C.public class Animal{ public abstract void speak();}D.public abstract class Animal{ public abstract void speak(){}}

考题 publicclassPet{}publicclassCatextendsPet{}执行代码Catc=newCat();Petp=(Pet)c;下列哪项是正确的? A.Petp=(Pet)c正常执行B.Petp=(Pet)c编译错误C.Petp=(Pet)c运行错误D.以上都不对

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

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

考题 现有:publicclassPet()publicclassCatextendsPet{)执行代码Catc-newCat();Petp=(Pet)c;后下列哪项是正确的?() A.Petp=(Pet)c运行错误B.Petp=(Pet)c编译错误C.Petp=(Pet)c止常执行D.以上都不对

考题 下列程序片段中,能通过编译的是( )。A.public abstract class Animal{public void speak( );}B.public abstract class Animal{public void speak( ){};}C.public class Animal{pubilc abstract void speak( );}D.public abstract class Animal{pubile abstract void speak( ){};}

考题 下列程序片段中,能通过编译的是( )。A.public abstract class Animal{ public void speak;}B.public abstract class Animal{ public void speak{);}C.public class Animal{ pubilc abstract void speak;}D.public abstract class Animal{ pubile abstract void speak{};}

考题 下列程序片段中,能通过编译的是( )。A.public abstract class Animal{ public void speak( );}B.public abstract class Animal{ public void speak( ){};}C.public class Animal{ pubilc abstract void speak( );}D.public abstract class Animal{ pubilc abstract void speak( ){};}

考题 下列程序片段中,能通过编译的是( )。 A.public abstract class Animal{ public void speak;}S 下列程序片段中,能通过编译的是( )。A.public abstract class Animal{ public void speak;}B.public abstract class Animal{ public void speak{);}C.public class Animal{ pubilc abstract void speak;}D.public abstract class Animal{ pubile abstract void speak{};}