单选题class Animal{ Animal getOne(){return new Animal();}}   class Dog extends Animal{   //insert code here   }   class AnimalTest{   public static void main(String[] args){   Animal[] animal={ new Animal(), new Dog()};   for(Animal a:animal){   Animal x= a.getOne();   }   }   }   和代码:   3a.Dog getOne() { return new Dog();}   3b.Animal getOne() { return new Dog();}   第3行中插入的哪项编译且运行无异常?A3a行或3b行B既非3a,也非3bC3a行D3b行

单选题
class Animal{ Animal getOne(){return new Animal();}}   class Dog extends Animal{   //insert code here   }   class AnimalTest{   public static void main(String[] args){   Animal[] animal={ new Animal(), new Dog()};   for(Animal a:animal){   Animal x= a.getOne();   }   }   }   和代码:   3a.Dog getOne() { return new Dog();}   3b.Animal getOne() { return new Dog();}   第3行中插入的哪项编译且运行无异常?
A

3a行或3b行

B

既非3a,也非3b

C

3a行

D

3b行


参考解析

解析: 暂无解析

相关考题:

有如下程序: include using namespaee std;class Animal{ public: virtual char*g 有如下程序:include<iostream>using namespaee std;c lass Animal{public:virtual char*getType( )const{return"Animal";}virtual char*getVoice( )const{return"Voice";}};class Dog:public Animal{public:char*getType( )const{return"Dog";}char*getVoice( )eonst{return"Woof";}};void type(AnimalA) {cout<<a.getType( );}void speak(Animal A) {eout<<a.getVoice( );}int main( ){Dog d;type(D) ;cout<<"speak";speak(D) ;cout return 0;}程序的输出结果是______。

下列程序片段中,能通过编译的是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(){}}

( 12 )有如下程序:#include iostreamusing namespace stdclass Animal{public:virtual char* getType () const { return "Animal" ; }virtual char* getVoice () const { return "Voice" ; }};Class Dog : public Animal {public:char* getType ( ) const {return "Dog" ; }char* getVoice ( ) const {return "Woof"}};void type ( Animal a ) {couta.getType ( ) ; }void speak ( Animal a ) {couta.getVoice ( ) ; }int main ( ) {Dog d; type ( d ) ; cout" speak" ; speak ( d ) ; coutendi;return 0;}运行时的输出结果是【 12 】 。

It can be inferred from the passage that all of the following are ways of producing new strains of influenza viruses EXCEPT______.A. two influenza viruses in the same animal recombiningB. animal viruses recombining with human virusesC. two animal viruses recombining in one animalD. two animal viruses recombining in a human

classAnimal{AnimalgetOne(){returnnewAnimal();}}classDogextendsAnimal{//insertcodehere}classAnimalTest{publicstaticvoidmain(String[]args){Animal[]animal={newAnimal(),newDog()};for(Animala:animal){Animalx=a.getOne();}}}和代码:3a.DoggetOne(){returnnewDog();}3b.AnimalgetOne(){returnnewDog();}第3行中插入的哪项编译且运行无异常?A.3a行或3b行B.既非3a,也非3bC.3a行D.3b行

1.classAnimal{AnimalgetOne(){returnnewAnimal();}}2.classDogextendsAnimal{3.//insertcodehere4.}5.6.classAnimalTest{7.publicstaticvoidmain(String[]args){8.Animal[]animal={newAnimal(),newDog()};9.for(Animala:animal){10.Animalx=a.getOne();11.}12.}13.}和代码:3a.DoggetOne(){returnnewDog();}3b.AnimalgetOne(){returnnewDog();}第3行中插入的哪项将编译且运行无异常?()A.3a行B.3b行C.3a行或3b行D.既非3a,也非3b

使用VC6打开考生文件夹下的工程test19_1,此工程包含一个源程序文件test19_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下:1:weight:5age:02:weight:7age:9源程序文件test19_1.cpp 清单如下:include <iostream.h>class animal{public:/**************** found *******************/friend void setvalue(animal,int);/**************** found *******************/void print()protected:int itsweight;int itsage;};void animal::print(){cout<<"weight:"<<itsweight<<end1;cout<<"age:"<<itsage<<end1;}void setvalue(animal ta,int tw){ta.itsweight=tw;ta.ihsage=0;}void setvalue(animal ta,int tw, int tn){ta.itsweight=tw;ta.itsage=tn;}void main(){/**************** found *******************/animal peppysetvalue(peppy,5);cout<<"1:"<<end1;peppy.print();setvalue(peppy,7,9);cout<<"2:"<<end1;peppy.print();}

有如下程序:ncludeiostreamusing namespace std;class Animal{public:virtual char*getType()const{return“Animal”;}virtual char*getVoice()const{return“Voice”;}};class Dog:public Animal{public:char*getType()const{rgturn“Dog”;}char*getVoice()const{retum“Woof”;}};void type(AnimalA){couta.getType();}void speak(AnimalA){couta.getVoice();}int main(){Dog d.type(D);tout“speak”;speak(D);coutendl;return 0;}运行时的输出结果是【 】

下列程序片段中,能通过编译的是( )。 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{};}

共用题干第三篇Animal Testing ControversyTo paraphrase 18th-century statesman Edmund Burke,"All that is needed for the triumph of a misguided cause is that good people do nothing." One such cause now seeks to end biomedical research because of the theory that animals have rights ruling out their use in research.Scientists need to respond forcefully to animal rights advocates,whose arguments are confusing the public and thereby threatening advances in health knowledge and care.Leaders of the animal rights movement target biomedical research because it depends on public funding,and few people understand the process of health care research.Hearing allegations of cruelty to animals in research settings,many are perplexed that anyone would deliberately harm an animal.For example,a grandmotherly woman staffing an animal rights booth at a recent street fair was distributing a brochure that encouraged readers not to use anything that comes from or is animals一no meat,no fur,no medicines.Asked if she opposed immunizations,she wanted to know if vaccines come from animal research.When assured that they do,she replied,"Then I would have to say yes."Asked what will happen when epidemics return,she said,"Don't worry,scientists will find some way of using computers."Such well-meaning people just don't understand.Scientists must communicate their message to the public in a compassionate,understandable way一in human terms,not in the language of molecular biology.We need to make clear the connection between animal research and a grandmother's hip replacement,a father's bypass operation,a baby's vaccinations,and even a pet's shots.To those who are unaware that animal research was nee-- ded to produce these treatments,as well as new treatments and vaccines,animal research seems wasteful at best and cruel at worst.Much can be done.Scientists could"adopt"middle school classes and present their own re-search.They should be quick to respond to letters to the editor,lest animal rights misinformation go unchallenged and acquire a deceptive appearance of truth.Research institutions could be opened to tours,to show that laboratory animals receive humane care.Finally,because the ultimate stakeholders are patients,the health research community should actively recruit to its cause not only well-known personalities such as Stephen Cooper,who has made courageous statements about the value of animal research,but all who receive medical treatment.If good people do nothing there is a real possibility that an uninformed citizenry will extinguish the precious embers of medical progress.From the text we learn that Stephen Cooper is________.A:a well-known humanist B:a medical practitionerC:an enthusiast in animal rights D:a supporter of animal research

classCatextendsAnimal{}对于下述代码说法正确的是()A、Cat是Animal的子类B、Animal是Cat的子类C、Cat是Animal的超类D、Animal一定是抽象类

interface Animal {  void soundOff();  }  class Elephant implements Animal {  public void soundOff() {  System.out.println(“Trumpet”);  }  }  class Lion implements Animal {  public void soundOff() { System.out.println(“Roar”);  }  }  class Alpha1 {  static Animal get( String choice ) {  if ( choice.equalsIgnoreCase( “meat eater” )) {  return new Lion();  } else {  return new Elephant();  }  }  }  Which compiles?()  A、 new Animal().soundOff();B、 Elephant e = new Alpha1();C、 Lion 1 = Alpha.get(“meat eater”);D、 new Alpha1().get(“veggie”).soundOff();

11. class Animal { public String noise() { return “peep”; } }  12. class Dog extends Animal {  13. public String noise() { return “bark”; }  14. }  15. class Cat extends Animal {  16. public String noise() { return “meow”; }  17. }  .....  30. Animal animal = new Dog();  31. Cat cat = (Cat)animal;  32. System.out.printIn(cat.noise());  What is the result?() A、 peepB、 barkC、 meowD、 Compilation fails.E、 An exception is thrown at runtime.

Which two demonstrate an “is a” relationship?()   A、 public interface Person { }  public class Employee extends Person { }B、 public interface Shape { }  public class Employee extends Shape { }C、 public interface Color { }  public class Employee extends Color { }D、 public class Species { }  public class Animal (private Species species;)E、 interface Component { }  Class Container implements Component ( Private Component[ ]children;  )

多选题Given: 10. interface Jumper { public void jump(); } ...   20. class Animal {} ...   30. class Dog extends Animal {   31. Tail tail;   32. }   ...   40. class Beagle extends Dog implements Jumper{   41. public void jump() {}  42. }   ...   50. class Cat implements Jumper{   51. public void jump() {}   52. }. Which three are true?()ACat is-a JumperBCat is-a AnimalCDog is-a JumperDDog is-a AnimalEBeagle has-a JumperFCat has-a AnimalGBeagle has-a Tail

单选题11. class Animal { public String noise() { return “peep”; } }  12. class Dog extends Animal {  13. public String noise() { return “bark”; }  14. }  15. class Cat extends Animal {  16. public String noise() { return “meow”; }  17. }  .....  30. Animal animal = new Dog();  31. Cat cat = (Cat)animal;  32. System.out.printIn(cat.noise());  What is the result?()A peepB barkC meowD Compilation fails.E An exception is thrown at runtime.

多选题Which three demonstrate an “is a” relationship?()Apublic class X { }  public class Y extends X { }Bpublic interface Shape { }  public interface Rectangle extends Shape{ }Cpublic interface Color { }  public class Shape { private Color color; }Dpublic interface Species { }  public class Animal { private Species species; }Epublic class Person { } public class Employee {  public Employee(Person person) { }Finterface Component { }  class Container implements Component { private Component[] children; }

单选题在Java中,类Animal中的方法printA()定义如下:  public void printA() {    Int a=10;    Int result =10%3;    System.out.println(result); }  在类Dog中方法printA()定义如下:  public void printA() {   Int a=10;    System.out.println(a/3); }  Dog类的定义如下:  Class Dog extends Animal{…}.  Animal animal=new Dog();  animal.printA();  以上语句输出结果为()。A 0B 1C 2D3E3.3333

多选题Which two demonstrate an “is a” relationship?()Apublic interface Person { }  public class Employee extends Person { }Bpublic interface Shape { }  public class Employee extends Shape { }Cpublic interface Color { }  public class Employee extends Color { }Dpublic class Species { }  public class Animal (private Species species;)Einterface Component { }  Class Container implements Component ( Private Component[ ]children;  )

单选题现有:  1. interface Animal {  2. void eat();  3. }  4.  5. // insert code here  6.  7. public class HouseCat extends Feline {  8. public void eat() { }  9. }   和五个声明:  abstract class Feline implements Animal { }  abstract class Feline implements Animal { void eat(); }  abstract class Feline implements Animal { public void eat(); }  abstract class Feline implements Animal { public void eat() { } }  abstract class Feline implements Animal { abstract public void eat(); }  分别插入到第5行,有几个可以通过编译?()A0B1C2D3

多选题Which the two demonstrate an “is a” relationship?()Apublic interface Person {}  Public class Employee extends Person {}Bpublic interface Shape {}  public interface Rectangle extends Shape {}Cpublic interface Color {}  public class Shape { private Color color; }Dpublic class Species {}  public class Animal { private Species species; }Einterface Component {} Class Container implements Component {private Component [] children;

多选题10. interface Jumper { public void jump(); }  ......  20. class Animal {}  ......  30. class Dog extends Animal { 31. Tail tail; 32. }  ......  40. class Beagle extends Dog implements Jumper {  41. public void jump() { }  42. }  .......  50. class Cat implements Jumper {  51. public void jump() { }  52. }  Which three are true?()ACat is-a AnimalBCat is-a JumperCDog is-a AnimalDDog is-a JumperECat has-a AnimalFBeagle has-a TailGBeagle has-a Jumper

单选题interface Animal {  void soundOff();  }  class Elephant implements Animal {  public void soundOff() {  System.out.println(“Trumpet”);  }  }  class Lion implements Animal {  public void soundOff() { System.out.println(“Roar”);  }  }  class Alpha1 {  static Animal get( String choice ) {  if ( choice.equalsIgnoreCase( “meat eater” )) {  return new Lion();  } else {  return new Elephant();  }  }  }  Which compiles?()A new Animal().soundOff();B Elephant e = new Alpha1();C Lion 1 = Alpha.get(“meat eater”);D new Alpha1().get(“veggie”).soundOff();

单选题现有:  1.  interface Animal  f      2.    void eat();      3.    }      4.  5.  // insert code here      6.  7. public class HouseCat implements Feline  {      8.    public void eat()    {  }     9.  }  和以下三个接口声明:  interface Feline extends Animal  (  )  interface Feline extends Animal  {void eat();    }  interface Feline extends Animal  {void eat()    {  }  }   分别插入到第5行,有多少行可以编译?A  0B  1C  2D  3

单选题现有:  interface Animal {       void eat () ;       }       //insert code here       public class HouseCat extends Feline {       public void eat() { }       }  和五个申明  abstract class Feline implements Animal { }  abstract  class  Feline  implements  Animal  {  void eat () ;  }  abstract class Feline implements Animal { public void eat();}  abstract class Feline implements Animal { public void eat() {}  }  abstract class Feline implements Animal { abstract public void eat();} 结果为:()A1B2C3D4

单选题1. interface Animal {   2. void eat();   3. }   4.   5. // insert code here   6.   7. public class HouseCat implements Feline {   8. public void eat() { }   9. }   和以下三个接口声明:   interface Feline extends Animal { }   interface Feline extends Animal { void eat(); }   interface Feline extends Animal { void eat() { } }   分别插入到第 5 行,有多少行可以编译?()A0B1C2D3

单选题1. class Animal { Animal getOne() { return new Animal(); } }  2. class Dog extends Animal {  3. // insert code here   4. }  5.  6. class AnimalTest {  7. public static void main(String [] args) {  8. Animal [] animal = { new Animal(), new Dog() } ;  9. for( Animal a : animal) {  10. Animal x = a.getOne();  11. }  12. }  13. }  和代码:  3a. Dog getOne() {  return new Dog();  }  3b. Animal getOne() {  return new Dog();  }  第 3 行中插入的哪项将编译且运行无异常?()A3a行B3b行C3a行或3b行D既非3a,也非3b