网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
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;


参考答案

参考解析
解析: 暂无解析
更多 “单选题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;” 相关考题
考题 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.

考题 现有包结构: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;

考题 classFoo{11.staticvoidalpha(){/*morecodehere*/}12.voidbeta(){/*morecodehere*/}13.}Whichtwoaretrue?() A.Foo.beta()isavalidinvocationofbeta().B.Foo.alpha()isavalidinvocationofalpha().C.Methodbeta()candirectlycallmethodalpha().D.Methodalpha()candirectlycallmethodbeta().

考题 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;

考题 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;

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

考题 现有如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.*;

考题 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().

考题 现有包结构:  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;

考题 现有如下包结构:  com |-- x | |-- Alpha.class | | | |-- y | |-- Beta.class | |-- Gamma.class  和类:  class Test { Alpha a; Beta b; Gamma c; }  哪三个必须加入到类 Test 中,以使其通过编译?()A、package y;B、package com;C、import com.x.*;D、import com.x.y.*

考题 表达式re.split(’/.+’,’alpha.beta...gamma..delta’)的值为()。

考题 1. class Alpha { void m1() {} }   2. class Beta extends Alpha { void m2() { } }   3. class Gamma extends Beta { }   4.   5. class GreekTest {   6. public static void main(String [] args) {   7. a Alpha [] a = {new Alpha(), new Beta(), new Gamma() };   8. for(Alpha a2 : a) {   9. a2.m1();   10. if (a2 instanceof Beta || a2 instanceof Gamma)   11. //insert code here   12. }   13. }   14. }   哪一行代码插入到第11行,将编译但是会在运行时产生异常?()  A、 a2.m2();B、 ((Beta)a2).m2();C、 ((Alpha)a2).m2();D、 ((Gamma)a2).m2();

考题 Given the JSP code: % request.setAttribute("foo", "bar"); %and the Classic tag handler code: 5. public int doStartTag() throws JspException { 6. // insert code here 7. // return int 8. } Assume there are no other "foo" attributes in the web application. Which invocation on the pageContextobject,inserted at line 6,assigns "bar" to the variable x?()A、String x = (String) pageContext.getAttribute("foo")B、String x = (String) pageContext.getRequestScope("foo")C、It is NOT possible to access the pageContext object from within doStartTagD、String x = (String) pageContext.getRequest().getAttribute("foo")E、String x = (String) pageContext.getAttribute("foo", PageContext.ANY_SCOPE)

考题 10. public class Foo implements java.io.Serializable {  11. private int x;  12. public int getX() { return x; }  12.publicFoo(int x){this.x=x; }  13. private void writeObject( ObjectOutputStream s)  14. throws IOException {  15. // insert code here  16. }  17. }  Which code fragment, inserted at line 15, will allow Foo objects to be correctly serialized and deserialized?() A、 s.writeInt(x);B、 s.serialize(x);C、 s.writeObject(x);D、 s.defaultWriteObject();

考题 10. interface Foo {}  11. class Alpha implements Foo {}  12. class Beta extends Alpha {}  13. class Delta extends Beta {  14. public static void main( String[] args) {  15. Beta x = new Beta();  16. // insert code here  17. }  18. }  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;

考题 interface Beta {}  class Alpha implements Beta {  String testIt() {  return “Tested”;  }  }  public class Main1 {  static Beta getIt() {  return new Alpha();  }  public static void main( String[] args ) {  Beta b = getIt();  System.out.println( b.testIt() );  }  }  What is the result?()  A、 TestedB、 Compilation fails.C、 The code runs with no output.D、 An exception is thrown at runtime.

考题 单选题10. interface Foo {}  11. class Alpha implements Foo {}  12. class Beta extends Alpha {}  13. class Delta extends Beta {  14. public static void main( String[] args) {  15. Beta x = new Beta();  16. // insert code here  17. }  18. }  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;

考题 单选题interface Beta {}  class Alpha implements Beta {  String testIt() {  return “Tested”;  }  }  public class Main1 {  static Beta getIt() {  return new Alpha();  }  public static void main( String[] args ) {  Beta b = getIt();  System.out.println( b.testIt() );  }  }  What is the result?()A  TestedB  Compilation fails.C  The code runs with no output.D  An exception is thrown at runtime.

考题 填空题表达式re.split(’/.+’,’alpha.beta...gamma..delta’)的值为()。

考题 单选题1. class Alpha { void m1() {} }   2. class Beta extends Alpha { void m2() { } }   3. class Gamma extends Beta { }   4.   5. class GreekTest {   6. public static void main(String [] args) {   7. a Alpha [] a = {new Alpha(), new Beta(), new Gamma() };   8. for(Alpha a2 : a) {   9. a2.m1();   10. if (a2 instanceof Beta || a2 instanceof Gamma)   11. //insert code here   12. }   13. }   14. }   哪一行代码插入到第11行,将编译但是会在运行时产生异常?()A  a2.m2();B  ((Beta)a2).m2();C  ((Alpha)a2).m2();D  ((Gamma)a2).m2();

考题 单选题10. public class Foo implements java.io.Serializable {  11. private int x;  12. public int getX() { return x; }  12.publicFoo(int x){this.x=x; }  13. private void writeObject( ObjectOutputStream s)  14. throws IOException {  15. // insert code here  16. }  17. }  Which code fragment, inserted at line 15, will allow Foo objects to be correctly serialized and deserialized?()A  s.writeInt(x);B  s.serialize(x);C  s.writeObject(x);D  s.defaultWriteObject();

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

考题 多选题现有如下包结构:  com |-- x | |-- Alpha.class | | | |-- y | |-- Beta.class | |-- Gamma.class  和类:  class Test { Alpha a; Beta b; Gamma c; }  哪三个必须加入到类 Test 中,以使其通过编译?()Apackage y;Bpackage com;Cimport com.x.*;Dimport com.x.y.*

考题 多选题现有包结构:  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; }  哪两行分别插入后可允许代码编译?()Apackage com.;Bimport com.x;Cpackage com.x;Dimport com.x.Alpha;

考题 单选题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;

考题 多选题10. class Foo {  11. static void alpha() { /* more code here */ }  12. void beta() { /* more code here */ }  13. }  Which two are true?()AFoo.beta() is a valid invocation of beta().BFoo.alpha() is a valid invocation of alpha().CMethod beta() can directly call method alpha().DMethod alpha() can directly call method beta().

考题 单选题Given the JSP code: and the Classic tag handler code: 5. public int doStartTag() throws JspException { 6. // insert code here 7. // return int 8. } Assume there are no other "foo" attributes in the web application. Which invocation on the pageContextobject,inserted at line 6,assigns "bar" to the variable x?()A String x = (String) pageContext.getAttribute(foo)B String x = (String) pageContext.getRequestScope(foo)C It is NOT possible to access the pageContext object from within doStartTagD String x = (String) pageContext.getRequest().getAttribute(foo)E String x = (String) pageContext.getAttribute(foo, PageContext.ANY_SCOPE)