



下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
Java核心技術(shù)(高階)_華東師范大學(xué)中國大學(xué)mooc課后章節(jié)答案期末考試題庫2023年Whatistheoutputofthefollowingapplication?packagezoo;publicclassPenguin{privateintvolume=1;privateclassChick{privatestaticintvolume=3;voidchick(){System.out.print("Honk("+Penguin.this.volume+")!");}}publicstaticvoidmain(String...eggs){Penguinpen=newPenguin();finalPenguin.ChicklittleOne=pen.newChick();littleOne.chick();}}
參考答案:
Thecodedoesnotcompile.
Giventheclassdeclarationbelow,whatexpressioncanbeusedtofillintheblanktoreturnthesizevariabledefinedintheBottleclass,printing14atruntime?packagebaby;finalpublicclassBottle{finalprivateintsize=14;finalprotectedclassInsert{privatefinalintsize=25;publicfinalintgetSize(){return____________________;}}finalInsertinsert=newInsert();finalpublicstaticvoidmain(String[]feed){System.out.print(newBottle().insert.getSize());}}
參考答案:
Bottle.this.size
Whichofthefollowingwouldbealegalmodulename?
參考答案:
com.book$
Whichofthefollowingclasstypescannotbemarkedfinalorabstract?
參考答案:
Anonymousinnerclass
給定以下代碼importjava.io.*;classLastError{privateTlastError;publicvoidsetError(Tt){lastError=t;System.out.println("LastError:setError");}}classStrLastErrorextendsLastError{publicStrLastError(Ss){}publicvoidsetError(Ss){System.out.println("StrLastError:setError");}}classTest{publicstaticvoidmain(String[]args){StrLastErrorerr=newStrLastError("Error");err.setError("Lasterror");}}其輸出結(jié)果是
參考答案:
Itresultsinacompilationerror.
Thecodedoesnotcompile,regardlessofwhatisplacedintheblank.packagepresent;interfaceToy{Stringplay();}publicclassGift{publicstaticvoidmain(String[]matrix){abstractclassRobot{}classTransformerextendsRobotimplementsToy{publicStringname="GiantRobot";publicStringplay(){return"DinosaurRobot";}}Transformerprime=newTransformer(){publicStringplay(){returnname;//y1}};System.out.print(prime.play()+""+name);}}
參考答案:
Noneoftheabove
以下代碼publicstatic>intfindFirstGreaterThan(T[]at,Telem){//...}經(jīng)過類型擦除,變成publicstaticintfindFirstGreaterThan(Object[]at,Objectelem){//...}
參考答案:
錯(cuò)誤
給定以下代碼importjava.util.*;publicclassExtendingGenerics{privatestatic<_____________,U>Uadd(Tlist,Uelement){list.add(element);returnelement;}publicstaticvoidmain(String[]args){Listvalues=newArrayList<>();add(values,"duck");add(values,"duck");add(values,"goose");System.out.println(values);}}以下哪個(gè)代碼添加進(jìn)去,可以使得程序正常編譯。
參考答案:
T
extends
Collection
以下代碼可以編譯通過。publicclassSingleton{publicstaticTgetInstance(){if(instance==null)instance=newSingleton();returninstance;}privatestaticTinstance=null;}
參考答案:
錯(cuò)誤
給定以下代碼,classShape{/*...*/}classCircleextendsShape{/*...*/}classRectangleextendsShape{/*...*/}classNode{/*...*/}那以下代碼可以編譯通過。Nodenc=newNode<>();Nodens=nc;
參考答案:
錯(cuò)誤
以下Pair泛型類publicclassPair{publicPair(Kkey,Vvalue){this.key=key;this.value=value;}publicKgetKey();{returnkey;}publicVgetValue();{returnvalue;}publicvoidsetKey(Kkey){this.key=key;}publicvoidsetValue(Vvalue){this.value=value;}privateKkey;privateVvalue;}經(jīng)過類型擦除后,變成以下類publicclassPair{publicPair(Objectkey,Objectvalue){this.key=key;this.value=value;}publicObjectgetKey(){returnkey;}publicObjectgetValue(){returnvalue;}publicvoidsetKey(Objectkey){this.key=key;}publicvoidsetValue(Objectvalue){this.value=value;}privateObjectkey;privateObjectvalue;}
參考答案:
正確
以下代碼能夠編譯通過.publicfinalclassAlgorithm{publicstaticTmax(Tx,Ty){returnx>y?x:y;}}
參考答案:
錯(cuò)誤
Whichisthefirstlinetocontainacompilererror?1:modulesnake{2:exportscom.snake.tail;3:exportscom.snake.fangstobird;4:requiresskin;5:requirestransitiveskin;6:}
參考答案:
Line5.
SupposeyouhaveastreampipelinewherealltheelementsareoftypeString.Whichofthefollowingcanbepassedtotheintermediateoperationsorted()?
參考答案:
(s,t)->s.length()-t.length()
Fillintheblankssothatbothmethodsproducethesameoutputforallinputs.privatestaticvoidlonger(Optionalopt){if(opt.____________())System.out.println("run:"+opt.get());}privatestaticvoidshorter(Optionalopt){opt.map(x->"run:"+x).____________(System.out::println);}
參考答案:
isPresent,ifPresent
以下代碼能夠編譯通過.publicstaticvoidprint(Listlist){for(Numbern:list)System.out.print(n+"");System.out.println();}
參考答案:
正確
Whatistrueofamodulecontainingafilenamedmodule-info.javawiththefollowingcontents?(Chooseallthatapply.)modulecom.food.supplier{}
參考答案:
Nopackagesinsidethemoduleareautomaticallyexported._Amainmethodinsidethemodulecanberun.
IfthismethodiscalledwithStream.of("hi"),howmanylinesareprinted?publicstaticvoidprint(Streamstream){Consumerprint=System.out::println;stream.peek(print).peek(print).map(s->s).peek(print).forEach(print);}
參考答案:
Four
給定以下代碼,classNodeimplementsComparable{publicintcompareTo(Tobj){/*...*/}//...}那以下代碼可以編譯通過。Nodenode=newNode<>();Comparablecomp=node;
參考答案:
正確
Alocalinnerclasscanaccesswhichtypeoflocalvariables(JDK8+)?I.finalII.privateIII.effectivelyfinal
參考答案:
IandIII
WhatcanbecreatedusingtheJavaPlatformModuleSystemthatcouldnotbecreatedwithoutit?(Chooseallthatapply.)
參考答案:
JMODfile_Smallerruntimeimagesfordistribution
Whatdoesthefollowingoutput?Streamchars=Stream.generate(()->'a');chars.filter(c->c<'b').sorted().findFirst().ifPresent(System.out::print);
參考答案:
Thecodeentersaninfiniteloop.
給定代碼importjava.util.*;classWash{Titem;publicvoidclean(Titems){System.out.println("Cleaned"+items.size()+"items");}}publicclassLaundryTime{publicstaticvoidmain(String[]args){Washwash=new____________wash.clean(Arrays.asList("sock","tie"));}}下列選項(xiàng)哪個(gè)可以添加到程序中,并輸出Cleaned2items。
參考答案:
extends,
Wash();
Whatistheoutputofthefollowingapplication?packageworld;publicclassMatrix{privateintlevel=1;classDeep{privateintlevel=2;classDeeper{privateintlevel=5;publicvoidprintReality(){System.out.print(level);System.out.print(""+Matrix.Deep.this.level);System.out.print(""+Deep.this.level);}}}publicstaticvoidmain(String[]bots){Matrix.Deep.Deepersimulation=newMatrix().newDeep().newDeeper();simulation.printReality();}}
參考答案:
522
WhichofthefollowingisanadvantageoftheJavaPlatformModuleSystem?
參考答案:
Encapsulatingpackages
WhatstatementbestdescribesthenotionofeffectivelyfinalinJava?
參考答案:
Alocalvariablethatisnotmarkedfinalbutwhoseprimitivevalueorobjectreferencedoesnotchangeafteritisinitialized.
Whatistheoutputofthefollowingapplication?packagespace;publicclassBottle{publicstaticclassShip{privateenumSail{//w1TALL{protectedintgetHeight(){return100;}},SHORT{protectedintgetHeight(){return2;}};protectedabstractintgetHeight();}publicSailgetSail(){returnSail.TALL;}}publicstaticvoidmain(String[]stars){Bottlebottle=newBottle();Shipq=bottle.newShip();//w2System.out.print(q.getSail());}}
參考答案:
Thecodedoesnotcompilebecauseoflinew2.
Whichofthefollowingcannotincludeastaticmethodinitsdefinition?
參考答案:
Localinnerclass
Whatistheoutputofthefollowingapplication?packageforest;publicclassWoods{staticclassTree{}publicstaticvoidmain(String[]leaves){intwater=10+5;finalclassOakextendsTree{//p1publicintgetWater(){returnwater;//p2}}System.out.print(newOak().getWater());}}
參考答案:
15
Whichstatementistrueofthefollowingmodule?zoo.staff|---zoo|--staff|--Vet.java
參考答案:
Thedirectorystructurewouldbeavalidmoduleifmodule-info.javawereaddeddirectlyunderneathzoo.staff.
Whatistheresultof
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 代銷商合同范本
- 借用證件購車合同范本
- 勞務(wù)雇傭附加合同范本
- 住院藥品購買合同范本
- Unit5 Fun club Section A1a-1d 教學(xué)設(shè)計(jì) 2024-2025學(xué)年人教版(2024)七年級英語上冊
- 5-3《人皆有不忍人之心》教學(xué)設(shè)計(jì)高二語文同步高效課堂(統(tǒng)編版 選擇性必修上冊)
- 中介獨(dú)家房屋合同范例
- 2024年南陽市第二人民醫(yī)院招聘考試真題
- 一建 總價(jià)合同范本
- 2024年貴州觀山湖區(qū)招聘城鎮(zhèn)公益性崗位人員筆試真題
- 悟哪吒精神做英雄少年開學(xué)第一課主題班會(huì)課件-
- 2025年2級注冊計(jì)量師專業(yè)實(shí)務(wù)真題附答案
- 2025年春季學(xué)期教導(dǎo)處工作計(jì)劃及安排表
- 果實(shí)品質(zhì)評價(jià)體系建立與應(yīng)用-深度研究
- 2024年江蘇省中小學(xué)生金鑰匙科技競賽(高中組)考試題庫(含答案)
- 智能制造技術(shù)在工業(yè)設(shè)計(jì)中的應(yīng)用
- 2025年湖南高速鐵路職業(yè)技術(shù)學(xué)院高職單招高職單招英語2016-2024年參考題庫含答案解析
- 吉林省吉林市普通中學(xué)2024-2025學(xué)年高三上學(xué)期二模試題 數(shù)學(xué)
- 2024年江西建設(shè)職業(yè)技術(shù)學(xué)院高職單招職業(yè)技能測驗(yàn)歷年參考題庫(頻考版)含答案解析
- 北京市東城區(qū)2024-2025學(xué)年高一上學(xué)期期末統(tǒng)一檢測歷史試卷(含答案)
- 人教版小學(xué)六年級下冊音樂教案全冊
評論
0/150
提交評論