CMS专题

单选题int index = 1;   boolean test = new Boolean;   boolean foo= test [index];  What is the result?()AFoo has the value of 0.BFoo has the value of null.CFoo has the value of true.DFoo has the value of false.EAn exception is thrown.FThe code will not compile

题目
单选题
int index = 1;   boolean test = new Boolean;   boolean foo= test [index];  What is the result?()
A

 Foo has the value of 0.

B

 Foo has the value of null.

C

 Foo has the value of true.

D

 Foo has the value of false.

E

 An exception is thrown.

F

 The code will not compile.

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

第1题:

Given:8.intindex=1:9.Boolean[]test=newboolcan[3];10.boolcanfoo=test[index];Whatistheresult()?

A.foohasthevalueof0.

B.foohasthevalueofnull.

C.foohasthevalueoftrue.

D.foohasthevalueoffalse.

E.An-exceptionisthrown.

F.Thecodewillnotcompile.


参考答案:D

第2题:

下列关于boolean类型的叙述中,正确的是( )。A.可以将boolean类型的数值转换为int类型的数值SX

下列关于boolean类型的叙述中,正确的是( )。

A.可以将boolean类型的数值转换为int类型的数值

B.可以将boolean类型的数值转换为字符串

C.可以将boolean类型的数值转换为char类型的数值

D.不能将boolean类型的数值转换为其他基本数据类型


正确答案:D
由于基本数据类型中boolean类型不是数字型,所以基本数据类型的转换是除了boolean类型以外的其他7种类型之间的转换。

第3题:

下列关于boolean类型的叙述中,正确的是

A.可以将boolean类型的数值转换为int类型的数值

B.可以将boolean类型的数值转换为字符串

C.可以将boolean类型的数值转换为char类型的数值

D.不能将boolean类型的数值转换为其他基本数据类型


正确答案:B

第4题:

int i,j; boolean booleanValue=(i==j)。


正确答案:错误

第5题:

执行下列程序段之后,变量b的值为______。 public class Test9 { public static void main(String[] args) { int i=12; int j=24; boolean b1=true; boolean b=(j%i== 0)&&(!b1) ||(j/i!=2); System.out.println(b); } }

A.true

B.假

C.1

D.0


正确答案:B
解析:表达式执行次序为:首先做!b1得到false:然后做j%i==0得到true;再做j/i!=2得到false:然后做&&得到false;最后是||得到false。

第6题:

intindex=1;boolean[]test=newBoolean[3];booleanfoo=test[index];Whatistheresult?()

A.Foohasthevalueof0.

B.Foohasthevalueofnull.

C.Foohasthevalueoftrue.

D.Foohasthevalueoffalse.

E.Anexceptionisthrown.

F.Thecodewillnotcompile.


参考答案:D

第7题:

当执行下面代码时,会输出( )。 Boolean b1 = new Boolean(true); Boolean b2 = new Boolean(true); if (b1 == b2) if (bi.equals(b2)) System. out.printin ("a"); else System. out. println ("b"); else if (bi.equals(b2)) System. out.println ("c"); else System. out.printIn("d");

A.a

B.b

C.c

D.d


正确答案:C
解析:本题考查对简单类型中的boolean类型的类封装的理解和掌握。对应于基本数据类型boolean的类封装是Boolean。它的构造函数的原型是Boalean(boolean value),将boolean值的数据转换为Boolean的对象。成员函数 equals()的原型是Boolean equals(Object Obj),当且仅当obj对象为Boolean对象且它的布尔值与该对象的布尔值相同时返回true。注意关系运算符==用来比较两个操作数的值是否相等。它一般只能用在基本数据类型间的比较,对于复杂的数据类型,这种比较往往都是没有意义的,对于这种没有意义的比较,其结果都为false。在本题的代码中,先创建两个Boolean类的对象b1和b2,并且它们的布尔值都为 true。然后直接对这两个对象进行==关系运算,这样的运算结果肯定为false,程序流程就走到第1层的else语句那里了,然后再用equals函数对两个对象的布尔值进行比较。因为它们的布尔值都为true,所以返回结果为true。这样输出的结果就为C。

第8题:

( 12 )下列布尔变量定义中,正确并且规范的是

A )BOOLEAN canceled = false;

B)boolean canceled = false;

C)boolean CANCELED = false;

D)boolean canceled = FALSE;


正确答案:B

第9题:

int index = 1;   String test = new String;   String foo = test[index];  What is the result?()

  • A、  Foo has the value “”
  • B、 Foo has the value null
  • C、 An exception is thrown
  • D、 The code will not compile

正确答案:B

第10题:

将有三个boolean值的数组初始化为true的是()

  • A、boolean[]b=newboolean[3]
  • B、"boolean[]b={true,true,true}"
  • C、"boolean[3]b={true,true,true}"
  • D、"boolean[]b=newboolean[3];b={true,true,true}"

正确答案:B

更多相关问题