多选题Given:  Integer i = new Integer (42);  Long l = new Long (42);  Double d = new Double (42.0);   Which two expression evaluate to true?()A(i = = l)B(i = = d)C(d = = l)D(i.equals(d))E(i.equals(i))F(i.equals(42))

题目
多选题
Given:  Integer i = new Integer (42);  Long l = new Long (42);  Double d = new Double (42.0);   Which two expression evaluate to true?()
A

(i = = l)

B

(i = = d)

C

(d = = l)

D

(i.equals(d))

E

(i.equals(i))

F

(i.equals(42))

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

第1题:

设有如下程序: Private Sub Form. Click( ) Dim s As Long,f As Long Dim n As Integer,i As Integer f=1 n=4 For i=1 To n f=f*i s=s+f Next i Print s End Sub 程序运行后,单击窗体,输出结果是( )。

A.32

B.33

C.34

D.35


正确答案:B
B。【解析】本题考查For循环,当f=1时,i=1,计算f=f*i=1*1=1;S=S十f=0十1=1,循环继续,当i=2时,f=f*i=1*2=2,S=s+f=1+2=3,循环继续,当i=3时,f=f*i=2*3=6,S=s+f=3+6=9,循环继凄,当i=4时,f=f*i=6*4=24,S=s+f=9+24=33,所以最后输出结果为33,答案选择B。

第2题:

public static void main(String[]args){Integer i=new Integer(1)+new Integer(2);switch(i){case3:System.out.println("three");break;default:System.out.println("other");break;}}Whatistheresult?()

A.three

B.other

C.Anexceptionisthrownatruntime.

D.Compilationfailsbecauseofanerroronline12.

E.Compilationfailsbecauseofanerroronline13.

F.Compilationfailsbecauseofanerroronline15.


参考答案:A

第3题:

( 18 )字面常量 42 、 4.2 、 42L 的数据类型分别是

A ) long 、 double int

B ) long 、 float 、 int

C ) int 、 double 、 long

D ) int 、 float 、 long


正确答案:C

第4题:

用整数10创建一个Integer类的对象,下列各语句中能完成此功能的是( )。

A.Integer i=new Integer(10);

B.Integer i=10;

C.int i=10;

D.Integer i=Integer(10);


正确答案:A
解析:Integer类是int类型的包装类,其创建和使用方法和一般的类相似,因此答案为A。

第5题:

阅读下面求质数的程序 import java. lang. Math. * ; public class MorePrimesTest{ public static void main(String[]args){ long[]primes=new long[20]; primes[0]2L; primes[1]3L; long number=5L; outer: for(int count=2; count<primes. length; number+ =2L){ long limit=(long)Math. ceil(Math. sqrt((double)number)); for(int i=1; i<count && primes[i]<limit; i+ +){ if(number______primes[i]==0L){ cotinue outer; } } for(int j=0; j<primes. length; j ++){ long n=primes[j]; System. out. println(n); } } } 在程序下画线处填入的正确选项是

A.&

B.*

C./

D.%


正确答案:D
解析:数组primes[]用于保存已经判断出来的质数,内层循环用来判断number是否为质数,判断的方法是用number去除数组中已判断的质数,看余数是否为0。若为0则不是质数,跳到外层循环。所以下画线处应是取余操作。

第6题:

Given:Integeri=newInteger(42);Longl=newLong(42);Doubled=newDouble(42.0);Whichtwoexpressionevaluatetotrue?()

A.(i==l)

B.(i==d)

C.(d==l)

D.(i.equals(d))

E.(i.equals(i))

F.(i.equals(42))


参考答案:D, E

第7题:

Integeri=newInteger(42);Long1=newLong(42);Doubled=newDouble(42.0);WhichtwoexpressionsevaluatetoTrue?()

A.(i==1)

B.(i==d)

C.(d==1)

D.(i.equals(d))

E.(d.equals(i))

F.(i.equals(42)


参考答案:D, E

第8题:

下面各选项中正确的是( )。 Ⅰ:long l=4990 Ⅱ:int i=4L Ⅲ:float f=1.1 Ⅳ:double d=34

A.Ⅱ、Ⅲ

B.Ⅱ、Ⅲ、Ⅳ

C.Ⅰ、Ⅳ

D.Ⅲ、Ⅳ


正确答案:C
解析:此题的考点是数字的表示方法和基本数据类型间的自动转换。没有小数点的数字被认为是int型数,带有小数点的数被认为是double型的数,其他的使用在数字后面加一个字母表示数据类型,加1或者L是 long型,加d或者D是double,加f或者F是float。可以将低精度的数字赋值给高精度的变量,反之,则需要进行强制类型转换。例如,将int、short、byte型数字赋值给long型变量时不需要显式的类型转换,反之,将 long型数字赋值给byte、short、int型变量时需要强制转换(int a=(int)123L)。Int I=4L不对,应该去掉后面的L,double d=34.4需要在后面加d。

第9题:

字面常量42、4.2、42L的数据类型分别是( )。 A.long,double、intB.lon9、float、int

字面常量42、4.2、42L的数据类型分别是( )。

A.long,double、int

B.lon9、float、int

C.int、double、long

D.int、float、long


正确答案:C
本题考查整型变量的类型和浮点变量的类型,42默认为int型数据,42后面加上L后,表示long型数据,4.2默认为double型数据。

第10题:

阅读下面求质数的程序 import java.lang.Math.*: public class MorePrimesTest { public static void main(String[] args) { long[] primes=new long[20]; primes[0]=2L; primes[0]=3L; long number=5L; outer: for(int count=2;count<primes.length;number+=2L) { long limit=(long)Math.ceil(Math.sqrt((double)number)); for(int i=1;i<count&&primes[i]<=limit;i++) { if(number primes[i]==OL)continue outer; } primes[count++]=number; } for(int J=0;j<primes.length;j++) { long n=primes[j]; System.out.println(n); } } } 程序下画线处应填入的正确选项是

A.&

B.*

C./

D.%


正确答案:D

更多相关问题