10. interface Jumper { public void jump(); }  ......  20. cl

题目
多选题
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?()
A

Cat is-a Animal

B

Cat is-a Jumper

C

Dog is-a Animal

D

Dog is-a Jumper

E

Cat has-a Animal

F

Beagle has-a Tail

G

Beagle has-a Jumper

参考答案和解析
正确答案: G,B
解析: 暂无解析
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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

}

}

这个错误不容易发现。


正确答案:

 

错。"interface Rollable extends Playable, Bounceable"没有问题。interface 可继承多个

interfaces,所以这里没错。问题出在interface Rollable 里的"Ball ball = new Ball("PingPang");"。

任何在interface 里声明的interface variable (接口变量,也可称成员变量),默认为public static

final。也就是说"Ball ball = new Ball("PingPang");"实际上是"public static final Ball ball = new

Ball("PingPang");"。在Ball 类的Play()方法中,"ball = new Ball("Football");"改变了ball 的

reference,而这里的ball 来自Rollable interface,Rollable interface 里的ball 是public static final

的,final 的object 是不能被改变reference 的。因此编译器将在"ball = new Ball("Football");"

这里显示有错。

第2题:

class A{

void P1(){cout<<"A111"};

void P2(){cout<<"A222"};

};

class B:public A{

void P1(){cout<<"B111"};

virtual void P2(){cout<<"B222"};

}

..........

A*cl=NULL;

cl=new A;

A->P1();

A->P2();

delete cl;

cl=NULL;

cl=new B;

A->P1();

A->P2();

delete cl;

cl=NULL;

..........

写出运行结果;


正确答案:
 

第3题:

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

第4题:

Which two are valid declarations within an interface definition?() 

  • A、 void methoda();
  • B、 public double methoda();
  • C、 public final double methoda();
  • D、 static void methoda(double d1);
  • E、 protected void methoda(double d1);

正确答案:A,B

第5题:

public interface A {  String DEFAULT_GREETING = “Hello World”;  public void method1();  }  A programmer wants to create an interface called B that has A as its parent. Which interface declaration is correct?() 

  • A、 public interface B extends A {}
  • B、 public interface B implements A {}
  • C、 public interface B instanceOf A {}
  • D、 public interface B inheritsFrom A {}

正确答案:A

第6题:

使用jdbc 编写class EnrollmentImpl 实现接口 Enrollment:

public interface Enrollment{

public void createStudent(Student student) throws Exception;

pubic void createCourse(Course course) throws Exception;

public void enroll(Student student, Course course) throws Exception;

public void exam(Student, Course course, float grade) throws Exception;

}


正确答案:
 

第7题:

10. public class ClassA {  11. public void count(int i) {  12. count(++i);  13. }  14. }  And:  20. ClassA a = new ClassA();  21. a.count(3);  Which exception or error should be thrown by the virtual machine?() 

  • A、 StackOverflowError
  • B、 NullPointerException
  • C、 NumberFormatException
  • D、 IllegalArgumentException
  • E、 ExceptionlnlnitializerError

正确答案:A

第8题:

interface A{

int x = 0;

}

class B{

int x =1;

}

class C extends B implements A {

public void pX(){

System.out.println(x);

}

public static void main(String[] args) {

new C().pX();

}

}


正确答案:

 

错误。在编译时会发生错误(错误描述不同的JVM 有不同的信息,意思就是未明确的

x 调用,两个x 都匹配(就象在同时import java.util 和java.sql 两个包时直接声明Date 一样)。

对于父类的变量,可以用super.x 来明确,而接口的属性默认隐含为 public static final.所以可

以通过A.x 来明确。

第9题:

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

  • A、 Cat is-a Animal
  • B、 Cat is-a Jumper
  • C、 Dog is-a Animal
  • D、 Dog is-a Jumper
  • E、 Cat has-a Animal
  • F、 Beagle has-a Tail
  • G、 Beagle has-a Jumper

正确答案:B,F

第10题:

interface Data { public void load(); }  abstract class Info { public abstract void load(); }  Which class correctly uses the Data interface and Info class?() 

  • A、 public class Employee extends Info implements Data { public void load() { /*do something*/ } }
  • B、 public class Employee implements Info extends Data { public void load() { /*do something*/ } }
  • C、 public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }
  • D、 public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }
  • E、 public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }
  • F、 public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }

正确答案:A

更多相关问题