单选题Given: Which code, inserted at line 16, will cause a java.lang.ClassCastException?()A Alpha a = x;B Foo f = (Delta)x;C Foo f = (Alpha)x;D Beta b = (Beta)(Alpha)x;

题目
单选题
Given: Which code, inserted at line 16, will cause a java.lang.ClassCastException?()
A

Alpha a = x;

B

Foo f = (Delta)x;

C

Foo f = (Alpha)x;

D

Beta b = (Beta)(Alpha)x;

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

classFoo{11.staticvoidalpha(){/*morecodehere*/}12.voidbeta(){/*morecodehere*/}13.}Whichtwoaretrue?()

A.Foo.beta()isavalidinvocationofbeta().

B.Foo.alpha()isavalidinvocationofalpha().

C.Methodbeta()candirectlycallmethodalpha().

D.Methodalpha()candirectlycallmethodbeta().


参考答案:B, C

第2题:

Given:Which three methods, inserted individually at line 14, will correctly complete class Two?()

A.int foo() { /* more code here */ }

B.void foo() { /* more code here */ }

C.public void foo() { /* more code here */ }

D.private void foo() { /* more code here */ }

E.protected void foo() { /* more code here */ }


参考答案:B, C, E

第3题:

14 Alpha buys goods from Beta. At 30 June 2005 Beta’s account in Alpha’s records showed $5,700 owing to Beta.

Beta submitted a statement to Alpha as at the same date showing a balance due of $5,200.

Which of the following could account fully for the difference?

A Alpha has sent a cheque to Beta for $500 which has not yet been received by Beta.

B The credit side of Beta’s account in Alpha’s records has been undercast by $500.

C An invoice for $250 from Beta has been treated in Alpha’s records as if it had been a credit note.

D Beta has issued a credit note for $500 to Alpha which Alpha has not yet received.


正确答案:D

第4题:

10. class Foo {  11. static void alpha() { /* more code here */ }  12. void beta() { /* more code here */ }  13. }  Which two are true?()

  • A、 Foo.beta() is a valid invocation of beta().
  • B、 Foo.alpha() is a valid invocation of alpha().
  • C、 Method beta() can directly call method alpha().
  • D、 Method alpha() can directly call method beta().

正确答案:B,C

第5题:

如果类Alpha继承了类Beta,则类Alpha称为派生类,类Beta称为【 】类。


正确答案:基
基 解析:在C++语言中,可以从一个类派生出另一个类。派生其他类的类称为基类(或父类),被派生的类称为派生类(或子类)。一个派生类可以从一个基类派生,也可以从多个基类派生。从一个基类派生的继承称为单继承,从多个基类派生的继承称为多继承。

第6题:

10.interfaceFoo{}11.classAlphaimplementsFoo{}12.classBetaextendsAlpha{}13.classDeltaextendsBeta{14.publicstaticvoidmain(String[]args){15.Betax=newBeta();16.//insertcodehere17.}18.}Whichcode,insertedatline16,willcauseajava.lang.ClassCastException?()

A.Alphaa=x;

B.Foof=(Delta)x;

C.Foof=(Alpha)x;

D.Betab=(Beta)(Alpha)x;


参考答案:B

第7题:

Given:Which code, inserted at line 16, will cause a java.lang.ClassCastException?()

A.Alpha a = x;

B.Foo f = (Delta)x;

C.Foo f = (Alpha)x;

D.Beta b = (Beta)(Alpha)x;


参考答案:B

第8题:

现有包结构:com|--x||--Alpha.class||||--y||--Beta.class||--Gamma.class和类://insertcodehereimportcom.*;importcom.x.y.*;classTest{Alphaa;Betab;Gammac;}哪两行分别插入后可允许代码编译?()

A.packagecom.;

B.importcom.x;

C.packagecom.x;

D.importcom.x.Alpha;


参考答案:C, D

第9题:

现有如F包结构:      com     |一一X      |    |一一Alpha.class     |    |      |    |一一y      I         |一一Beta.class     |      |l-- Gamma.class    和类:      class Test  {  Alpha a;  Beta b; Gamma c;  }  哪三个必须加入到类Test中,以使其通过编译?() 

  • A、 package y;
  • B、 package com;
  • C、 import com.x.y.*;
  • D、 import com.x.*;

正确答案:B,C,D

第10题:

现有包结构:  com |-- x | |-- Alpha.class | | | |-- y | |-- Beta.class | |-- Gamma.class  和类:  //insert code here  import com.*;  import com.x.y.*;  class Test { Alpha a; Beta b; Gamma c; }  哪两行分别插入后可允许代码编译?() 

  • A、package com.;
  • B、import com.x;
  • C、package com.x;
  • D、import com.x.Alpha;

正确答案:C,D

更多相关问题