现有:  interface Animal

题目

现有:  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();} 结果为:()      

  • A、1
  • B、2
  • C、3
  • D、4
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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 recombining

B. animal viruses recombining with human viruses

C. two animal viruses recombining in one animal

D. two animal viruses recombining in a human


正确答案:D
[解析] 见第三段,根据句意可知选项D为正确答案。

第2题:

Which command shows if an access list is assigned to an interface?()

A. show ip interface [interface] access-lists

B. show ip access-lists interface [interface]

C. show ip interface [interface]

D. show ip access-lists [interface]


参考答案:C

第3题:

下列程序片段中,能通过编译的是

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(){}}


正确答案:A

第4题:

Which three demonstrate an “is a” relationship?() 

  • A、 public class X {  }     public class Y extends X { }
  • B、 public interface Shape { }     public interface Rectangle extends Shape{ }
  • C、 public interface Color { }     public class Shape { private Color color; }
  • D、 public interface Species { }     public class Animal { private Species species; }
  • E、 public class Person { }    public class Employee {      public Employee(Person person) { }
  • F、 interface Component { }     class Container implements Component {   private Component[] children; }

正确答案:A,B,F

第5题:

现有:   public interface A {}   以下哪项声明是合法的?() 

  • A、a = new A();
  • B、 A[] a = new A[];
  • C、 A[] a = new A[10];
  • D、 以上皆错

正确答案:C

第6题:

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


正确答案:A
A。【解析】Java中一个类是一个abstract类的子类,它必须具体实现父类的abstract方法。如果一个类中含有abstract方法,那么这个类必须用abstract来修饰(abstract类也可以没有abstract方法)。有abstract方法的父类只声明,由继承它的子类实现。所以选A。

第7题:

classCatextendsAnimal{}对于下述代码说法正确的是()

  • A、Cat是Animal的子类
  • B、Animal是Cat的子类
  • C、Cat是Animal的超类
  • D、Animal一定是抽象类

正确答案:A

第8题:

( 12 )有如下程序:

#include <iostream>

using 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 {return "Dog" ; }

char* getVoice ( ) const {return "Woof"}

};

void type ( Animal& a ) {cout<<a.getType ( ) ; }

void speak ( Animal a ) {cout<<a.getVoice ( ) ; }

int main ( ) {

Dog d; type ( d ) ; cout<<" speak" ; speak ( d ) ; cout<<endi;

return 0;

}

运行时的输出结果是【 12 】 。


正确答案:

第9题:

现有:  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、  0
  • B、  1
  • C、  2
  • D、  3

正确答案:C

第10题:

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();

正确答案:D

更多相关问题