电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

2024年全国软考程序员考试部分例题VIP免费

2024年全国软考程序员考试部分例题_第1页
1/19
2024年全国软考程序员考试部分例题_第2页
2/19
2024年全国软考程序员考试部分例题_第3页
3/19
全国软考程序员考试部分例题全国软考程序员考试部分例题全国软考程序员考试部分例题例题1:choosethethreevalididentifiersfromthoselistedbelow.a.idolikethelongnameclassb.$bytec.constd._oke.3_case解答:a,b,d点评:java中的标示符必须是字母、美元符($)或下划线(_)开头。关键字与保留字不能作为标示符。选项c中的const是java的保留字,因此不能作标示符。选项e中的3_case以数字开头,违反了java的规则。例题2:howcanyouforcegarbagecollectionofanobject?a.garbagecollectioncannotbeforcedb.callsystem.gc().c.callsystem.gc(),passinginareferencetotheobjecttobegarbagecollected.d.callruntime.gc().e.setallreferencestotheobjecttonewvalues(null,forexample).解答:a点评:在java中垃圾搜集是不能被强迫立即执行的。调用system.gc()或runtime.gc()静态措施不能保证垃圾搜集器的立即执行,由于,也许存在着更高优先级的线程。因此选项b、d不对的。选项c的错误在于,system.gc()措施是不接受参数的。选项e中的措施可以使对象在下次垃圾搜集器运行时被搜集。例题3:considerthefollowingclass:1.classtest(inti){2.voidtest(inti){3.system.out.println(iamanint.);4.}5.voidtest(strings){6.system.out.println(iamastring.);7.}8.9.publicstaticvoidmain(stringargs[]){10.testt=newtest();11.charch=y12.t.test(ch);13.}14.}whichofthestatementsbelowistrue?(chooseone.)a.line5willnotcompile,becausevoidmethodscannotbeoverridden.b.line12willnotcompile,becausethereisnoversionoftest()thatrakesacharargument.c.thecodewillcompilebutwillthrowanexceptionatline12.d.thecodewillcompileandproducethefollowingoutput:iamanint.e.thecodewillcompileandproducethefollowingoutput:iamastring.解答:d点评:在第12行,16位长的char型变量ch在编译时会自动转化为一种32位长的int型,并在运行时传给voidtest(inti)措施。例题4:whichofthefollowinglinesofcodewillcompilewithouterror?a.inti=0;if(i){system.out.println(hi);}b.booleanb=true;booleanb2=true;if(b==b2){system.out.println(sotrue);}c.inti=1;intj=2;if(i==1||j==2)system.out.println(ok);d.inti=1;intj=2;if(i==1|j==2)system.out.println(ok);解答:b,c点评:选项a错,由于if语句后需要一种boolean类型的体现式。逻辑操作有tandleextendsshape{}c.publicinterfacecolorable{}publicclassshapeimplementscolorable{}d.publicclassspecies{}publicclassanimal{privatespeciesspecies;}e.interfacecomponent{}classcontainerimplementscomponent{privatecomponent[]children;}解答:d,e点评:在java中代码重用有两种也许的方式,即组合(hasa关系)和继承(isa关系)。hasa关系是通过定义类的属性的方式实现的;而isa关系是通过类继承实现的。本例中选项a、b、c体现了isa关系;选项d、e体现了hasa关系。例题6:whichtwostatementsaretruefortheclassjava.util.treeset?(choosetwo)a.theelementsinthecollectionareordered.b.thecollectionisguaranteedtobeimmutable.c.theelementsinthecollectionareguaranteedtobeunique.d.theelementsinthecollectionareaccessedusingauniquekey.e.theelementsinthecollectionareguaranteedtobesynchronized解答:a,c点评:treeset类实现了set接口。set的特点是其中的元素惟一,选项c对的。由于采用了树形存储方式,将元素有序地组织起来,因此选项a也对的。例题7:trueorfalse:readershavemethodsthatcanreadandreturnfloatsanddoubles.a.tureb.false解答:b点评:reader/writer只处理unicode字符的输入输出。float和double可以通过stream进行i/o.例题8:whatdoesthefollowingpaint()methoddraw?1.publicvoidpaint(graphicsg){2.g.drawstring(anyquestion,10,0);3.}a.thestringanyquestion?,withitstop-leftcornerat10,0b.alittlesquigglecomingdownfromthetopofthecomponent.解答:b点评:drawstring(stringstr,intx,inty)措施是使用目前的颜色和字符...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

2024年全国软考程序员考试部分例题

您可能关注的文档

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部