CMS专题

单选题int index = 1;  boolean[] test = new Boolean[3];  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 com

题目
单选题
int index = 1;  boolean[] test = new Boolean[3];  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.

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

第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=false;boolean b=true;boolean c=(a&&b)&&(!b);boolean result=(a&am

boolean a=false; boolean b=true; boolean c=(a&&b)&&(!b); boolean result=(a&b)&(!b); 执行完后,正确的结果是( )。

A.c=false;result=false

B.c=true,result=true

C.c=true;result=false

D.c=false;result=true


正确答案:A
解析:本题考查Java中的运算。首先要清楚,“&&”是逻辑与运算符;“!”是逻辑非运算符;“&”是按位与运算符。按照逻辑运算符“a&&b”是false,“!b”是false,所以c是false。“a及b”是false,所以result是false。要注意区分“&&”和“&”,以及运算符之间的优先级关系,本题虽然没有涉及,但也要作为重点掌握。

第3题:

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

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

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

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

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


正确答案:B

第4题:

下列代码的编译或执行结果是( )。 public class Myval{ public static void main(string args[]){ MyVal m=new MyVal; aMethod; } public void aMethod{ boolean b[]=new Boolean[5]; System.OUt.println(b[0]); } }

A.1

B.null

C.0

D.编译错误


正确答案:A
A。【解析】boolean类型的变量值只有ture或false,b[0]的默认初始值为false。

第5题:

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

A.BOOLEAN canceled=false;

B.boolean canceled=false;

C.boolean CANCELED=false;

D.boolean canceled=FALSE;


正确答案:B
解析:本题考查Java的简单数据类型的变量定义及Java的命名约定。Java中的命名规则中包含如下几条:
  (1)变量名、方法名首单词小写,其余单词只有首字母大写;
  (2)常量完全大写;
  (3)变量命名采用完整的英文描述符,第一个字母小写,任何中间单词的首字母大写。
  Java语言区分大小写。简单数据类型布尔型用boolean表示。布尔型数据只有两个值: true(真)和false(假)。
  经过上述分析可知,选项B和选项C都能正确的定义一个布尔型变量,但是选项C的变量名CANCELED不符合Java中的命名规则,而选项B的变量名符合变量名的命名规则。因此,选项B是符合规范的布尔变量定义语句。
  本题的正确答案是选项B。

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

阅读下面程序 public class My Val{ public static void main(String args[]){ My Val m=new My Val(); m. amethod(); } public void amethod(){ boolean b[]=new Boolean[5]; } } 程序编译或运行结果是

A.1

B.null

C.

D.编译不能过


正确答案:C
解析:编译能通过,但不在控制台输出任何信息。程序只是实例化了一个布尔类型的数组,且由于此数组为局部变量,不会自动初始化,故其中值都为null。

第8题:

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

A )BOOLEAN canceled = false;

B)boolean canceled = false;

C)boolean CANCELED = false;

D)boolean canceled = FALSE;


正确答案:B

第9题:

在匹配器(Matcher)类中,用于寻找下一个模式匹配串的方法是( )。 A.static boolean matchesSXB

在匹配器(Matcher)类中,用于寻找下一个模式匹配串的方法是( )。

A.static boolean matches

B.boolean matcher.find

C.int matcher.start

D.int matcher.end


正确答案:A
A。【解析】本题考查考生对Java中的匹配器(Mateher)类的理解。Matcher类用于将一个输入字符串input和模式串pattern相比较。Booleanmateher.find方法用于寻找下一个模式匹配串;intmatcher.start方法用于返回匹配串的一个起始索引整数值;intmatcher.end方法用于返回匹配串的一个终止索引整数值。而用于输入字符串与模式串比较的方法是staticbooleanmatches,选项A正确。

第10题:

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

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

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

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

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

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


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

更多相关问题