![Java數(shù)據(jù)類型的轉(zhuǎn)化專項(xiàng)測(cè)試題附答案_第1頁(yè)](http://file4.renrendoc.com/view2/M00/17/0E/wKhkFmZ2HXWAN5-7AAFBi9ET44k529.jpg)
![Java數(shù)據(jù)類型的轉(zhuǎn)化專項(xiàng)測(cè)試題附答案_第2頁(yè)](http://file4.renrendoc.com/view2/M00/17/0E/wKhkFmZ2HXWAN5-7AAFBi9ET44k5292.jpg)
![Java數(shù)據(jù)類型的轉(zhuǎn)化專項(xiàng)測(cè)試題附答案_第3頁(yè)](http://file4.renrendoc.com/view2/M00/17/0E/wKhkFmZ2HXWAN5-7AAFBi9ET44k5293.jpg)
![Java數(shù)據(jù)類型的轉(zhuǎn)化專項(xiàng)測(cè)試題附答案_第4頁(yè)](http://file4.renrendoc.com/view2/M00/17/0E/wKhkFmZ2HXWAN5-7AAFBi9ET44k5294.jpg)
![Java數(shù)據(jù)類型的轉(zhuǎn)化專項(xiàng)測(cè)試題附答案_第5頁(yè)](http://file4.renrendoc.com/view2/M00/17/0E/wKhkFmZ2HXWAN5-7AAFBi9ET44k5295.jpg)
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
Java數(shù)據(jù)類型的轉(zhuǎn)化專項(xiàng)測(cè)試題附答案1.Inthecodesegmentbelow,assumethattheintvariablesaandbhavebeenproperlydeclaredandinitialized.
intc=a;
intd=b;
c+=3;
d--;
doublenum=c;
num/=d;
Whichofthefollowingbestdescribesthebehaviorofthecodesegment?Thecodesegmentstoresthevalueof(a+3)/binthevariablenum.Thecodesegmentstoresthevalueof(a+3)/(b-1)inthevariablenum.(正確答案)Thecodesegmentstoresthevalueof(a+3)/(b-2)inthevariablenum.Thecodesegmentstoresthevalueof(a+3)/(1-b)inthevariablenum.Thecodesegmentcausesaruntimeerrorinthelastlineofcodebecausenumistypedoubleanddistypeint.2.Considerthefollowingcodesegment,whichisintendedtofindtheaverageoftwopositiveintegers,xandy.
intx;
inty;
intsum=x+y;
doubleaverage=(double)(sum/2);
Whichofthefollowingbestdescribestheerror,ifany,inthecodesegment?Thereisnoerror,andthecodeworksasintended.Intheexpression(double)(sum/2),thecasttodoubleisappliedtoolate,sotheaveragewillbelessthantheexpectedresultforevenvaluesofsum.Intheexpression(double)(sum/2),thecasttodoubleisappliedtoolate,sotheaveragewillbegreaterthantheexpectedresultforevenvaluesofsum.Intheexpression(double)(sum/2),thecasttodoubleisappliedtoolate,sotheaveragewillbelessthantheexpectedresultforoddvaluesofsum.(正確答案)Intheexpression(double)(sum/2),thecasttodoubleisappliedtoolate,sotheaveragewillbegreaterthantheexpectedresultforoddvaluesofsum.3.Considerthefollowingcodesegment.
doublenum=9/4;
System.out.print(num);
System.out.print("");
System.out.print((int)num);
Whatisprintedasaresultofexecutingthecodesegment?222.02(正確答案)2.02.02.2522.252.04.Considerthefollowingcodesegment.
doublex=(int)(5.5-2.5);
doubley=(int)5.5-2.5;
System.out.println(x-y);
Whatisprintedasaresultofexecutingthecodesegment?-1.0-0.50.00.5(正確答案)1.05.Considerthefollowingcodesegment.
intw=1;
intx=w/2;
doubley=3;
intz=(int)(x+y);
Whichofthefollowingbestdescribestheresultsofcompilingthecodesegment?Thecodesegmentcompileswithouterror.(正確答案)Thecodesegmentdoesnotcompile,becausetheintvariablexcannotbeassignedtheresultoftheoperationw/2.Thecodesegmentdoesnotcompile,becausetheintegervalue3cannotbeassignedtothedoublevariabley.Thecodesegmentdoesnotcompile,becausetheoperandsoftheadditionoperatorcannotbeofdifferenttypesintanddouble.Thecodesegmentdoesnotcompilebecausetheresultoftheadditionoperationisoftypedoubleandcannotbecasttoanint.6.Considerthefollowingcodesegment.
doublex=4.5;
inty=(int)x2;
System.out.print(y);
Whatisprintedasaresultofexecutingthecodesegment?8(正確答案)8.099.0107.Considerthefollowingcodesegment.
inta=5;
intb=4;
intc=2;
a=3;
b+=a;
b/=c;
System.out.print(b);
Whatisprintedwhenthecodesegmentisexecuted?249(正確答案)9.5198.Considerthefollowingcodesegment.
num+=num;
num=num;
Assumethatnumhasbeenpreviouslydeclaredandinitializedtocontainanintegervalue.Whichofthefollowingbestdescribesthebehaviorofthecodesegment?Thevalueofnumistwotimesitsoriginalvalue.Thevalueofnumisthesquareitsoriginalvalue.Thevalueofnumistwotimesthesquareofitsoriginalvalue.Thevalueofnumisthesquareoftwiceitsoriginalvalue.(正確答案)Itcannotbedeterminedwithoutknowingtheinitialvalueofnum.9.Considerthefollowingcodesegment.
intx=5;
x+=62;
x-=3/2;
Whatvalueisstoredinxafterthecodesegmentexecutes?-1.51915.516(正確答案)10.Considerthefollowingcodesegment,wherekandcountareproperlydeclaredandinitializedintvariables.
k++;
k++;
count++;
k--;
count++;
k--;
Whichofthefollowingbestdescribesthebehaviorofthecodesegment?Thecodesegmentleavesbothkandcountunchanged.Thecodesegmentincreasesbothkandcountby2.Thecodesegmentincreaseskby4andcountby2.Thecodesegmentleaveskunchangedandincreasescountby2.(正確答案)Thecodesegmentincreaseskby2andleavescountunchanged.11.Considerthefollowingcodesegment.
inta=4;
intb=5;
a++;
b++;
intc=a+b;
a-=1;
System.out.println(a+c);
Whatisprintedwhenthecodesegmentisexecuted?9101415(正確答案)2512.Thefollowingcodesegmentisintendedtoroundvaltothenearestintegerandprinttheresult.
doubleval=-0.7;
introundedVal=(int)(val+0.5);
System.out.println(roundedVal);
Whichofthefollowingbestdescribesthebehaviorofthecodesegment?Thecodesegmentworksasintended.ThecodesegmentdoesnotworkasintendedbecausevalandroundedValshouldbedeclaredasthesamedatatype.Thecodesegmentdoesnotworkasintendedbecausetheexpression(val+0.5)shouldbecasttoadoubleinsteadofanint.Thecodesegmentdoesnotworkasintendedbecausevalshouldbecasttoanintbefore0.5isaddedtoit.Thecodesegmentdoesnotworkasintendedbecausetheexpression(int)(val+0.5)roundstothenearestintegeronlywhenvalispositive.(正確答案)13.Considerthefollowingcodesegment.
System.out.print(Idonotfearcomputers.);//Line1
System.out.println(Ifearthelackofthem.);//Line2
System.out.println(--IsaacAsimov);//Line3
Thecodesegmentisintendedtoproducethefollowingoutputbutmaynotworkasintended.
Idonotfearcomputers.Ifearthelackofthem.
--IsaacAsimov
Whichchange,ifany,canbemadesothatthecodesegmentproducestheintendedoutput?Inline1,printshouldbechangedtoprintln.Inlines2and3,printlnshouldbechangedtoprint.ThestatementSystem.out.println()shouldbeinsertedbetweenlines2and3.Inlines1,2,and3,thetextthatappearsinparenthesesshouldbeenclosedinquotationmarks.(正確答案)Nochangeisneeded;thecodesegmentworkscorrectlyasis.14.Considerthefollowingcodesegment.
System.out.print();//Line1
System.out.print("");//Line2
System.out.println();//Line3
System.out.println("");//Line4
Thecodesegmentisintendedtoproducethefollowingoutput,butmaynotworkasintended.
Whichlineofcode,ifany,causesanerror?Line1(正確答案)Line2Line3Line4Thecodesegmentworksasintended.15.Considerthefollowingcodesegment.
System.out.print("One");//Line1
System.out.print("Two");//Line2
System.out.print("Three");//Line3
System.out.print("Four");//Line4
Thecodesegmentisintendedtoproducethefollowingoutput,butdoesnotworkasintended.
OneTwo
ThreeFour
Whichofthefollowingchangescanbemadesothatthecodesegmentproducestheintendedoutput?Changingprinttoprintlninline1onlyChangingprinttoprintlninline2only(正確答案)Changingprinttoprintlninline3onlyChangingprinttoprintlninlines2and3onlyChangingprinttoprintlninlines1,2,3,and416.Considerthefollowingcodesegment.
Whatisprintedasaresultofexecutingthecodesegment?
0124(正
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 公司餐廳裝修合同范本
- 副總勞務(wù)合同范本
- 產(chǎn)品轉(zhuǎn)讓合同范本
- 商業(yè)使用門(mén)面房出租合同范本
- 修腳店入股合同范例
- 二手升降機(jī)銷(xiāo)售合同范例
- 工程服務(wù)類合同范本
- 教學(xué)儀器購(gòu)銷(xiāo)合同范本
- 出境社旅游合同范本
- 農(nóng)業(yè)種植項(xiàng)目合同范例
- 2024年燃?xì)廨啓C(jī)值班員技能鑒定理論知識(shí)考試題庫(kù)-下(多選、判斷題)
- 交通法規(guī)課件
- (優(yōu)化版)高中地理新課程標(biāo)準(zhǔn)【2024年修訂版】
- 《Python程序設(shè)計(jì)》課件-1:Python簡(jiǎn)介與應(yīng)用領(lǐng)域
- 各類心理量表大全
- DB12T990-2020建筑類建設(shè)工程規(guī)劃許可證設(shè)計(jì)方案規(guī)范
- DB11T 1481-2024生產(chǎn)經(jīng)營(yíng)單位生產(chǎn)安全事故應(yīng)急預(yù)案評(píng)審規(guī)范
- 《氓》教學(xué)設(shè)計(jì) 2023-2024學(xué)年統(tǒng)編版高中語(yǔ)文選擇性必修下冊(cè)
- 《網(wǎng)店運(yùn)營(yíng)與管理》第3版 課件全套 白東蕊 第1-11章 網(wǎng)上開(kāi)店概述- 移動(dòng)網(wǎng)店運(yùn)營(yíng)
- 2024年全國(guó)國(guó)家電網(wǎng)招聘之電網(wǎng)計(jì)算機(jī)考試歷年考試題(附答案)
- 化學(xué)元素周期表注音版
評(píng)論
0/150
提交評(píng)論