Java核心技術(shù)(高階)-華東師范大學(xué)中國大學(xué)mooc課后章節(jié)答案期末考試題庫2023年_第1頁
Java核心技術(shù)(高階)-華東師范大學(xué)中國大學(xué)mooc課后章節(jié)答案期末考試題庫2023年_第2頁
Java核心技術(shù)(高階)-華東師范大學(xué)中國大學(xué)mooc課后章節(jié)答案期末考試題庫2023年_第3頁
Java核心技術(shù)(高階)-華東師范大學(xué)中國大學(xué)mooc課后章節(jié)答案期末考試題庫2023年_第4頁
免費預(yù)覽已結(jié)束,剩余4頁可下載查看

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quá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){//...}

參考答案:

錯誤

給定以下代碼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);}}以下哪個代碼添加進去,可以使得程序正常編譯。

參考答案:

T

extends

Collection

以下代碼可以編譯通過。publicclassSingleton{publicstaticTgetInstance(){if(instance==null)instance=newSingleton();returninstance;}privatestaticTinstance=null;}

參考答案:

錯誤

給定以下代碼,classShape{/*...*/}classCircleextendsShape{/*...*/}classRectangleextendsShape{/*...*/}classNode{/*...*/}那以下代碼可以編譯通過。Nodenc=newNode<>();Nodens=nc;

參考答案:

錯誤

以下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;}}

參考答案:

錯誤

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"));}}下列選項哪個可以添加到程序中,并輸出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)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論