CMS专题

单选题现有:  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  (  ) 

题目
单选题
现有:  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
解析: 暂无解析
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Given:10. interface Data { public void load(); }11. abstract class Info { public abstract void load(); }Which class correctly uses the Data interface and Info class?()()

A.

B.

C.

D.

E.

F.


参考答案:A

第2题:

1. public interface A {  2. public void doSomething(String thing);  3. }  1. public class AImpl implements A {  2. public void doSomething(String msg) { }  3. }  1. public class B {  2. public A doit() {  3. // more code here  4. }  5.  6. public String execute() { 7. // more code here  8. }  9. }  1. public class C extends B {  2. public AImpl doit() {  3. // more code here  4. }  5.  6. public Object execute() {  7. // more code here  8. }  9. }  Which statement is true about the classes and interfaces in the exhibit?() 

  • A、 Compilation will succeed for all classes and interfaces.
  • B、 Compilation of class C will fail because of an error in line 2.
  • C、 Compilation of class C will fail because of an error in line 6.
  • D、 Compilation of class AImpl will fail because of an error in line 2.

正确答案: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题:

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

第5题:

Given classes defined in two different files:  1. package util;  2. public class BitUtils {  3. private static void process(byte[] b) { }  4. }  1. package app;  2. public class SomeApp {  3. public static void main(String[] args) {  4. byte[] bytes = new byte[256];  5. // insert code here  6. }  7. }  What is required at line 5 in class SomeApp to use the process method of BitUtils?() 

  • A、 process(bytes);
  • B、 BitUtils.process(bytes);
  • C、 app.BitUtils.process(bytes);
  • D、 util.BitUtils.process(bytes);
  • E、 import util.BitUtils. *; process(bytes);
  • F、 SomeApp cannot use the process method in BitUtils.

正确答案:F

第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题:

现有:  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

第8题:

现金收入业务的处理程序为()。

A、1.核对收款依据;2.收取款项;3.开具收款证明

B、1.收取款项;2.核对收款依据;3.开具收款证明

C、1.开具收款证明;2.核对收款依据;3.收取款项

D、1.核对收款依据;2.开具收款证明;3.收取款项


参考答案:A

第9题:

写出分属于下列科的校园植物。 李亚科1.()2.()3.() 苹果亚科1.()2.()3.() 绣线菊亚科1.()2.() 蔷薇亚科() 十字花科1.()2.() 藜科1.()2.() 蓼科() 堇菜科() 卫矛科() 蝶形花科1.()2.()3.()


正确答案:杏;李;桃;苹果;梨;山楂;珍珠梅;风箱果;玫瑰;独行菜;荠菜;猪毛菜;藜;巴天酸模;早开堇菜;桃叶卫矛;刺槐;紫花苜蓿;披针叶黄华

第10题:

1. class super {  2. public float getNum() {return 3.0f;}  3. }  4.    5. public class Sub extends Super { 6.   7. }   Which method, placed at line 6, will cause a compiler error?()  

  • A、  Public float getNum()   {return 4.0f; }
  • B、  Public void getNum ()  { }
  • C、  Public void getNum (double d)   { }
  • D、  Public double getNum (float d) {retrun 4.0f; }

正确答案:B

更多相关问题