福建农林大学java-a卷(自己写的答案

福建农林大学java-a卷(自己写的答案

ID:32785044

大小:87.91 KB

页数:15页

时间:2019-02-15

福建农林大学java-a卷(自己写的答案_第1页
福建农林大学java-a卷(自己写的答案_第2页
福建农林大学java-a卷(自己写的答案_第3页
福建农林大学java-a卷(自己写的答案_第4页
福建农林大学java-a卷(自己写的答案_第5页
资源描述:

《福建农林大学java-a卷(自己写的答案》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、2012——2013学年第二学期课程名称:JavaProgramming考试时间120Minutes专业2010年级班学号姓名题号—・•-四11.总得分得分评卷人签字复核人签字S—、选择题(每题1分,共10分)1.下面变量声明屮存在错误的是(b)Idoublex=14.7;inty=x;IIdoublex=14.7;inty=(int)x;IIIintx=14;doubley=x;(D)IIIonly(D)22isnegative(A)None(B)Ionly(C)IIonly2.下血程序片段的输出是(cl)intnum=22;if(num>0)if(num%5==0)System.

2、out.println(num);elseSystem.out.println(num+Misnegative11);(A)22(B)4(C)2isnegative1.下面程序片段的输出是(d)intx=10,y=0;while(x>5){y=3;while(y

3、进制数是(c)(A)32(B)225(C)255(D)2563.类Clown有一个无参构造函数,类型为ArrayList的变量list已经初始化,卜面会产生IndexOutOfBoundsException错误的是(a)(A)for(inti=0;i<=list.size();i++)list.sct(i,newClown());(B)list.add(list.size(),newClown());(C)Clownc=list.get(list.size());(D)Clownc=list.remove(list.size());4.下面接口定义存在的错误是(cl)p

4、ublicinterfaceBad{voidsomcMcthod(Stringpassword){System.out.println(uPsst!Thepasswordisn+password);}}(A)Amethodinaninterfaceshouldbedeclaredpublic.(B)Amethodinaninterfaceshouldbedeclaredabstract.(C)Thereshouldnotbeamethodimplementation.(A)Thereshouldbeaclassimplementationprovided.1.假设一个求N个数的平均数

5、的算法存在语句average=sum/N,其屮N和sum都是整数。在一个使用该算法的程序中,程序员忘记对N是否为0进行检查。如果N等于0,错误被发现的时刻是(d)(A)Atcompiletime(B)Atedittime(C)AssoonasthevalueofNisentered(D)Duringruntime2.Thisquestionisbasedonthefollowingdeclarations:StringstrA="CARROT",strB="Carrot",strC="car";假设大写字母小于小写字母,下面表达式为true的是(c)(A)strA.compareTo

6、(strB)<0&&strB.compareTo(strC)>0(B)strC.comparcTo(strB)<0&&strB.comparcTo(strA)<0(C)strB.compareTo(strC)<0&&strB.compareTo(strA)>0(D)!(strA.compareTo(strB)==0)&&sirB.compareTo(strA)<03.RefertothencxtlntlnRangcmethodbelow:/*Postcondition:返回一个low到high的随机整数(包括low和high).*/publicintnextIntInRange(in

7、tlow,inthigh){return/*expression*/}Which/*expression*/willalwaysreturnavaluethatsatisfiesthepostcondition?(c)(A)(int)(Math.random()*high)+low;(B)(int)(Math.random()*(high-low))+low;(C)(int)(Math.random()*(high-low+1))+low;(D)(int)

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。