1Z0-809-CHS Java SE 8 Programmer II認(rèn)證考試題庫(附答案)_第1頁
1Z0-809-CHS Java SE 8 Programmer II認(rèn)證考試題庫(附答案)_第2頁
1Z0-809-CHS Java SE 8 Programmer II認(rèn)證考試題庫(附答案)_第3頁
1Z0-809-CHS Java SE 8 Programmer II認(rèn)證考試題庫(附答案)_第4頁
1Z0-809-CHS Java SE 8 Programmer II認(rèn)證考試題庫(附答案)_第5頁
已閱讀5頁,還剩99頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

lZ0-809-CHS:JavaSE8ProgrammerH認(rèn)證考試題南附答案)

一、單選題

1.Giventhecodefragment:

classCallerThreadimplementsCallable<String>{

Stringstr;

publicCallerThread(Strings)(this.str=s;)

publicStringcall()throwsException{

returnstr.concat(''Call**);

and

publicstaticvoidmain(String[]args)throwsInterruptedExceptionr

ExecutionException

(

ExecutorServicees=Executors.newFixedThreadPool(4);//linenl

Futurefl=es.submit(newCallerThread(''Call**));

Stringstr=fl.get().toString();

System.out.printin(str);

Whichstatementistrue?

A、TheprogramprintsCaIICaIIandterminates.

B、TheprogramprintsCaIICalIanddoesnotterminate.

C\ApiIationerroroccursatIinen1.

D、AnExecutionExceptionisthrownatruntime.

答案:B

2.Given:

publicclassCustomer{

privateStringEName;

privateStringIName;

privatestaticintcount;

publiccustomer(Stringfirst.Stringlast){fName=first,IName=last;

++count;}

static{count=0;}

publicstaticintgetCount(){returncount;)

}

publicclassApp{

publicstaticvoidmain(String[]args)(

w

Customercl=newCustomer(*'Larryr"Smith");

Customerc2=newCustomer("Pedro","Gonzales");

Customerc3=newCustomer("Penny","Jones");

Customerc4=newCustomer("Lars","Svenson");

c4=null;

c3=c2;

System.out.printIn(Customer.getCount());

)

}

Whatistheresu11?

A、0

B、2

C、3

D、4

E、5

答案:D

3.Giventhecodefragment:

Stringstr=**Javaisaprogramminglanguage**;

ToIntFunction<String>indexVal=str::indexOf;//linenl

intx=indexVal.applyAsInt(''Java**);//linen2

System.out.printin(x);

Whatistheresu11?

A、0

B、1

C、ApiIationerroroccursatIinen1.

DvApiIationerroroccursatIinen2.

答案:A

4.GiventherecordsfromtheSTUDENTtabIe:

sidsnamesemai

111Jamesjames@

112Janejane@

114Johnjohn@

Giventhecodefragment:

publicstaticvoidmain(String[)args)throwsSQLException{

//codetoloadandregistervalidjdbcdrivergohere

Connectioncon=DriverManager.getConnection(URLrusername,password);

Statementst=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

ResultSet.CONCUR_UPDATABLE);

st.execute("SELECT*FROMstudent-);

ResultSetrs=st.getResultSet();

rs.absolute(3);

rs.moveToInsertRow();

rs.updatelnt(1r113);

rs.updateString(2,wJannet");

rs.updateString(3r**jannetQ*);

rs.updateRow();

rs.refreshRow();

System.out.printIn(rs.getlnt(1)+w:"+rs.getString(2)+w:n+rs.getStr

(3));

AssumethatthellRL,username,andpasswordarevaIid.

Whatistheresu11?

A、TheSTUDENTtabIeisnotupdatedandtheprogramprints:114:John:johnuni.

B、TheSTUDENTtabIeisupdatedwiththerecord:113:Jannet:jannetuni.andthep

rogramprints:114:John:johnuni.

C、TheSTUDENTtabIeisupdatedwiththerecord:113:Jannet:jannetuni.andthep

rogramprints:113:Jannet:jannetuni.

DvASQLExceptionisthrownatruntime.

答案:D

5.Giventhecodefragments:

4.voiddoStuff()throwsArithmeticExceptionrNumberFormatExceptionrException

(

5.if(Math.random()>-lthrownewException("Tryagain");

6.}

and

24.try(

25.doStuff():

26.}catch(ArithmeticException|NumberFormatException|Exceptione){

27.System.out.printin(e.getMessage());}

28?catch(Exceptione){

29.System.out.printIn(e.getMessage());)

30.}

WhichmodificationenabIesthecodetoprintTryagain?

A、menttheIines28,29and30.

B、RepIaceIine26with:}catch(Exception|ArithmeticException|NumberForma

tExceptione){

C、RepIaceIine26with:}catch(ArithmeticException|NumberFormatException

e){

D、RepIaceIine27with:throwe;

答案:C

6.Given:

interfaceRideable{CargetCar(Stringname);)

classCar{

privateStringname;

publicCar(Stringname){

=name;

)

)

WhichcodefragmentcreatesaninstanceofCar?

A、Carauto=Car("MyCar")::new;

B、Carauto=Car::new;Carvehicle=auto::getCar(uMyCarn);

CvRideabIerider=Car::new;CarvehicIe=rider.getCar(uMyCarJ,);

D\Carvehicle=RideabIe::new::getCar(uMyCar,J);

答案:c

7.Giventhecodefragment:

Deque<String>queue=newArrayDequeO();

queue.add("Susan");

queue.add(??Allen*);

queue.add(**David*);

System.out.printIn(queue.pop());

System.out.printin(queue?remove());

System.out.printIn(queue);

Whatistheresu11?

AvDavidDavid[Susan,AIIen]

B、SusanSusan[Susan,Allen]

GSusanAIlen[David]

D、DavidAIIen[Susan]

E、SusanAIlen[Susan,David]

答案:C

8.Giventhecodefragment:

List<String>codes=Arrays.asList("DOC","MPEG","JPEG");

codes.forEach(c->System.out.print(c+";

Stringfmt=codes<stream()

.filter(s->s.contains("PEG"))

?reduce((srt)->s+t).get();

System,out.printin(''Xn**+fmt);

Whatistheresu11?

A、DOCMPEGJPEGMPEGJPEG

B、DOCMPEGMPEGJPEGMPEGMPEGJPEG

C、MPEGJPEGMPEGJPEG

DvTheorderoftheoutputisunpredictabIe.

答案:A

9.Giventhecodefragments:

classRimplementsRunnable{

publicvoidrun()(System.out.printIn("Run.)

classCimplementsCallable<String>{

publicStringcall()throwsException{return"Call...H;)

)

and

ExecutorServicees=Executors.newSingleThreadExecutor();

es.execute(newR());//linenl

Future<String>fl=es.submit(newC());//linen2

System.out.printin(fl.get());

es,shutdown();

Whatistheresu11?

A、TheprogramprintsRun…andthrowsanexception.

B、ApiIationerroroccursatIinen1.

C、Run???CaII

D、ApiIationerroroccursatIinen2.

答案:c

10.Given:

classBook{

intid;

Stringname;

publicBook(intid,Stringname){

this.id=id;

=name;

}

publicbooleanequals(Objectobj){//linenl

booleanoutput=false;

Bookb=(Book)obj;

if(.equals(bname)))

output=true;

)

returnoutput;

)

}

andthecodefragment:

Bookbl=newBook(101,''JavaPrograming");

Bookb2=newBook(102,**JavaPrograming*);

System.out.printin(bl.equals(b2));//linen2whih

statementistrue?

AvTheprogramprintstrue.

B、TheprogramprintsfaIse.

C\ApiIationerroroccurs.ToensuresuccessfuIpiIation,repIaceIinenlwith:

booIeanequaIs(Bookobj){

DvApiIationerroroccurs.ToensuresuccessfuIpiIation,repIaceIinen2with:

System,out.printIn(b1.equaIs((Object)b2));

答案:A

11.GiventhedefinitionoftheCountrycIass:

publicclasscountry{

publicenumContinent{ASIA,EUROPE)

Stringname;

Continentregion;

publicCountry(Stringna,Continentreg){

name=na,region=reg;

)

publicStringgetName(){returnname;}

publicContinentgetRegion(){returnregion;)

}

Andthecodefragment:

List<Country>couList=Arrays.asList(

newCountry(''Japan**,Country.Continent.ASIA)9

newCountry('Italy”,Country?Continent.EUROPE),

newCountry(''Germany**,Country.Continent.EUROPE));

Map<Country?ContinentzList<String>>regionNames=couList.stream()

.collect(Collectors.groupingBy(Country::getRegion,

Collectors<mapping(Country::getNamerCollectors.toList()))));

System.out.printin(regionNames);

A、{EUROPE=[Italy,Germany],ASIA=[Japan]}

B、{ASIA=[Japan],EUROPE=[Italy,Germany]}

C\{EUROPE=[Germany,ItaIy],ASIA=[Japan]}

D、{EUROPE=:Germany],EUROPE=[Italy],ASIA=[Japan]}

答案:B

12.Giventhecodefragment:

finalList<String>list=newCopyOnWriteArrayLisrO();

finalAtomicIntegerai=newAtomiclnteger(G);

finalCyclicBarrierbarrier=newCyclicBarrier(2rnewRunnable(){

publicvoidrun(){System.out.printin(list);>

});

Runnabler=newRunnable(){

publicvoidrun(){

try(

Thread.sleep(1000*ai.incrementAndGet());

li?t.add(wXw);

barrier.await();

)catch(Exceptionex)(

newThread(r).start();

newThread(r).start();

newThread(r).start();

newThread(r).start();

Whatistheresu11?

A、[X][X,X][X,X,X][X,X,x,x]

B、[X,X]

C、[X][X,X][X,X,X]

D、[X,X][X,X,X,X]

答案:D

13.GiventhecontentoftheempIoyee.txtfiIe:

Everyworkerisamaster.

GiventhattheempIoyee.txtfiIeisaccessibIeandthefiIeaIIemp.txtdoesNOTex

ist,andthecodefragment:

try(

List<String>content=Files.readAllLines(Paths.get(Memployee?txt

content.stream().forEach(line->{

try(

Files.write(

Paths.get(nallemp.txt"),

line.getBytes(),

StandardOpenOption.APPEND

);

}catch(lOExceptione)(System.out.printIn("Exception1");

});

}catch(lOExceptione)(System.out.printin("Exception2");)

Whatistheresu11?

AvException1

B、Exception2

CvTheprogramexecutes,doesNOTaffectthesystem,andproducesNOoutput.

D、aIIemp.txtiscreatedandthecontentofempIoyee.txtiscopiedtoit.

答案:A

14.Giventhecodefragment:

UnaryOperator<Integer>uol=s->s*2;linenl

List<Double>loanValues=Arrays.asList(1000.0r2000.0);

loanValues.stream()

?filter(Iv->Iv〉=1500)

.map(Iv->uol.apply(Iv))

.forEach(s->System.out?print(s+"*));

Whatistheresu11?

A、4000.0

B、4000

C、ApiIationerroroccursatIinen1.

DvApiIationerroroccursatIinen2.

答案:D

15.Thedata.doc,data,txtanddata.xmIfiIesareaccessibIeandcontaintext.Gi

venthecodefragment:

Whatistheresu11?

AvTheprogramprintsthecontentofdata.txtfiIe.

B、Theprogramprints:ExceptionOException

C、ApiIationerroroccursatIinen1.

DvTheprogramprintsthecontentofthethreefiIes.

答案:A

16.Giventhecodefragment:

List<Integer>values=Arrays.asList(1,2,3);

values.stream()

?map(n->n*2)//linenl

.peek(System.out::print)//linen2

?count();

Whatistheresu11?

A、246

B、Thecodeproducesnooutput.

C\ApiIationerroroccursatIinen1.

DvApiIationerroroccursatIinen2.

答案:A

LocaleCurrencySymbolCurrencyCode

US$USD

17.——

andthecodefragment?

doubled=15;

Locale1=newLocale("enRr"US");

NumberFormatformatter=NumberFormat.getCurrencyInstance(1);

System.out.println(formatter.format(d));

Whatistheresu11?

A、$15,00

B、15$

C、USD15.00

D、USD$15

答案:A

18.Giventhecodefragment:

9.Connectionconn=DriveManager.getConnection(dbURLruserName,password);

10.Stringquery="SELECTidFROMEmployee*;

11.try(Statementstmt=conn.createStatement()){

12.ResultSetrs=stmt.executeQuery(query);

13.stmt.executeQuery(''SELECTidFROMCustomerw);

14.while(rs.next()){

15?//processtheresults

16.Systern.out.printIn(''EmployeeID:"+rs.get工nt("id"));

17.}

18.}catch(Exceptione){

19.System*out.printin(''Error**);

20.)

Assumethat:

TherequireddatabasedriverisconfiguredinthecIasspath.

TheappropriatedatabaseisaccessibIewiththedbllRL,userName,andpassWordex

ists.

TheEmpIoyeeandCustomertabIesareavaiIabIeandeachtabIehasidcoIumnwithaf

ewrecordsandtheSQLqueriesarevaIid.

WhatistheresuItofpiIingandexecutingthiscodefragment?

A、TheprogramprintsempIoyeeIDs.

B、TheprogramprintscustomerIDs.

C、TheprogramprintsError.

DvpiIationfaiIsonIine13.

答案:c

19.Giventhecodefragment:

Pathsource=Paths.get(''/data/december/log.txt**);

Pathdestination=Paths.get("/data");

Files.copy(source^destination);

Whatistheresu11?

A、AfiIewiththenameIog.txtiscreatedinthe/datadirectoryandthecontentof

the/data/december/1og.txtfiIeiscopiedtoit.

B、TheprogramexecutessuccessfuIIyanddoesNOTchangethefiIesystem.

CvAFiIeNotFoundExceptionisthrownatruntime.

DvAFiIeAIreadyExistsExceptionisthrownatruntime.

答案:D

20.WhichcIassdefinitionpiIes?

classVehicle{

intid;

publicvoidstart()(

publicclassEngine{inteNo?id;}

)

A、,

classComputer{

privateCardsCard=newSoundcard();

privateabstractclassCard<)

privateclassSoundCaxdextendsCard{}

B、

classBlock{

intbno;

staticclassCounter(

intlocator;

Counter(){locator=bno;}

)

C、

classProduct{

interfaceMoveable{voidmove();)

MoveaiolemProduct,newMoveable(){

voidmove(){)

D、

答案:B

21.WhichstatementistrueabouttheDriverManagercIass?

A、ItreturnsaninstanceofConnection.

B、itexecutesSQLstatementsagainstthedatabase.

C\ItonIyqueriesmetadataofthedatabase.

Dvitiswrittenbydifferentvendorsfortheirspecificdatabase.

答案:A

22.Giventhecodefragments:

publicclassBookimplementsComparator<Book>

Stringname;

doubleprice;

publicBook(){}

publicBook(Stringname,doubleprice)

=name;

this.price=price;

}

publicintcompare(Bookbl.Bookb2)(

returnpareTo();

)

publicStringtoString(){

returnname++price;

)

and

List<Book>books=Arrays.asList(newBook(''BeginningwithJava”,2),newbook

GuidetoJavaTour",3));

Collections.sort(books,newBook());

System.out.print(books);

Whatistheresu11?

A、[AGuidetoJavaTour:3.0,BeginningwithJava:2.0]

B、[BeginningwithJava:2,AGuidetoJavaTour:3]

C\ApiIationerroroccursbecausetheBookcIassdoesnotoverridetheabstractm

ethodpareTo().

DvAnExceptionisthrownatruntime.

答案:A

23.Giventhecodefragment:

Pathpl=Paths.get(''/Pics/MyPic.jpegw);

System.out.printin(pl.getNameCount()+

+pl.getName(1)+

""+pl.getFileName());

AssumethatthePicsdirectorydoesNOTexist.Whatistheresu11?

AvAnexceptionisthrownatruntime.

B\2:MyPic.jpeg:MyPic.jpeg

G1:Pics:/Pics/MyPic.jpeg

D\2:Pics:MyPic.jpeg

答案:B

24.Giventhecodefragment:

publicstaticvoidmain(String[]args)throwslOException{

BufferedReaderbrCopy=null;

try(BufferedReaderbr=newBufferedReader(newFileReader

(''employee.txt**))){//

linenl

br?lines().forEach(c->System.out.printIn(c));

brCopy=br;//linen2

}

brCopy?ready();//linen3;

}

AssumethatthereadymethodoftheBufferedReader,whencaIIedonacIosedBuffer

edReader,throwsanexception,andempIoyee.txtisaccessibIeandcontainsvaIi

dtext.Whatistheresu11?

A、ApiIationerroroccursatIinen3.

B、ApiIationerroroccursatIinen1.

C、ApiIationerroroccursatIinen2.

D、ThecodeprintsthecontentoftheempIoyee.txtfiIeandthrowsanexceptionat

Iinen3.

答案:D

25.Whichstatementistrueaboutjava.util,stream.Stream?

A、Astreamcannotbeconsumedmorethanonce.

B、Theexecutionmodeofstreamscanbechangedduringprocessing.

C、Streamsareintendedtomodifythesourcedata.

D、AparaIIeIstreamisaIwaysfasterthananequivaIentsequentiaIstream.

答案:A

26.Giventhecodefragment:

List<String>empDetails=Arrays.asList(''lOOrRobinrHR",

w

"200,Mary,AdminServicesr

*101,PeterrHR");

empDetails.stream()

.filter(s->s.contains(**1))

.sorted()

.forEach(System.out::printIn);//linenl

Whatistheresu11?

A、100,Robin,HR101,Peter,HR

B、ApiIationerroroccursatIinen1.

C、100,Robin,HR101,Peter,HR200,Mary,AdminServices

D、100,Robin,HR200,Mary,AdminServices101,Peter,HR

答案:A

27.Given:

classWorkerextendsThread{

CyclicBarriercb;

publicWorker(CyclicBarriercb)(this.cb=cb;}

publicvoidrun(){

try{

cb.await();

System*out.printIn(''Worker...*);

}catch(Exceptionex){)

)

}

classMasterimplementsRunnable{//linenl

publicvoidrun(){

System.out.println(''Master...**);

)

)

Andthecodefragment:

Mastermaster=newMaster();

//linen2

Workerworker=newWorker(cb);

worker.start();

YouhavebeenaskedtoensurethattherunmethodsofboththeWorkerandMastercIas

sesareexecuted.Whichmodificationmeetstherequirement?

A、AtIinen2,insertCycIicBarriercb=newCycIicBarrier(2,master);

B、RepIaceIinen1witheIassMasterextendsThread{

CvAtIinen2,insertCycIicBarriercb=newCycIicBarrier(1,master);

D、AtIinen2,insertCycIicBarriercb=newCycIicBarrier(master);

答案:c

28.Given:

classProduct{

Stringname;

intqty;

publicStringtoString(){

returnname;

)

publicProduct(Stringname,intqty){

=name;

this.qty=qty;

)

staticclassProductFilter{

publicbooleanisAvailable(Productp){//lin?nl

returnp.qty>=10;

)

)

)

andthecodefragment:

List<Product>products=Arrays.asList(

newProduct("MotherBoard**t5),

newProduct("Speaker",20)>;

products.stream()

.filter(Product.ProductFilter::isAvailable)//linen2

.forEach(p->System.out.printIn(p));

WhichmodificationenabIesthecodefragmenttoprintSpeaker?

AvImpIementPredicateintheProduct.ProductFiItercIassandrepIaceIinen2w

ith.fiIter(p->p.ProductFiIter.test(p))

B、RepIaceIinen1with:publicstaticbooIeanisAvaiIabIe(Productp){

CvRepIaceIinen2with:.fiIter(p->p.ProductFiIter::isAvaiIabIe(p))

D、RepIaceIinen2with:.fiIter(p->Product::ProductFiIter::isAvaiIabIe())

答案:B

29.Giventhecodefragment:

//linenl

Doubled=str.average()?getAsDouble();

System.out.println("Average="+d);

WhichshouIdbeinsertedintoIinen1toprintAverage=2.5?

A、IntStreamstr=Stream.of(1,2,3,4);

B、IntStreamstr=IntStream,of(1,2,3,4);

C、DoubIeStreamstr=Stream,of(1.0,2.0,3.0,4.0);

DvStreamstr二Stream,of(1,2,3,4);

答案:B

30.GiventherecordsfromtheEmpIoyeetabIe:

eidename

111Tom

112

113Donald

Andgiventhecodefragment:

try(

Connectionconn=DriverManager.getConnection(URL,userName,

password);

Statementst=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVEr

ResultSet.CONCUR__UPDATABLE);

st.execute(''SELECT*FROMEmployee**);

ResultSetrs=st.getResultSet();

while(rs.next()){

if(rs.getlnt(1)==112){

rs.updateString(2,''Jack**);

}

)

rs.absolute(2);

System.out.println(rs.getlnt(1)?""+rs.getString(2));

}catch(SQLExceptionex){

System,out.printin(''Exceptionisraised**);

Assumethat:

TherequireddatabasedriverisconfiguredinthecIasspath.

TheappropriatedatabaseaccessibIewiththellRL,userName,andpassWordexists.

Whatistheresu11?

A、TheEmpIoyeetabIeisupdatedwiththerow:112Jackandtheprogramprints:112

Jerry

B、TheEmpIoyeetabIeisupdatedwiththerow:112Jackandtheprogramprints:112

Jack

C、TheEmpIoyeetabIeisnotupdatedandtheprogramprints:112Jerry

DvTheprogramprintsExceptionisraised.

答案:c

31.Giventhecontent:

MessagesBpertiesfile:

username=EnterUserName

password?EnterPassword

MessagesBundle_fr_FR.propertiesfile:

username=Entrezlenomd*utilisateur

password=Entrezlemotdepasse

Andthecodefragment:

LocalecurrentLocale?newLocale.Builder().setRegion(*FR").setLanguage(*fr*).build(

ResourceBundlemessages=ResourceBundle.getBundle("MessagesBundle*,currentLocale);

Enumeration<String>names=messages.getKeys();

while(namas.hasMoreElements())<

Stringkey=names.nextElement();

Stringname■messages.getString(key);

System.out.println(key+"="+name);

)

Whatistheresu11?

Avusername=EntrezIenomd'utiIisateurpassword=EntrezIemotdepasse

B、username=EnterUserNamepassword=EnterPassword

C、ApiIationerroroccurs.

D、Theprogramprintsnothing.

答案:A

32.Giventhecodefragments:

publicstaticOptional<String>getCountry(Stringloc)

Optional<String>couName=Optional?empty();

if("Paris".equals(loc))

couName.Optional.of(MFranceN);

elseif(wMuxnbaiN.equals(loc))

couName=Optional.of(HIndiaH);

returncouName;

md

Optional<String>cityl=getCountry(wParis");

Optional<String>city2=getCountry(HLasVegasr,);

System,out.printIn(cityl.orElse("NotFoundw));

if(city2.isPresent())

city2.ifPresent(x->System.out.printIn(x));

else

System.out.printin(city2.orElse("NotFound"));

Whatistheresu11?

A、FranceOptionaI[NotFound]

B\OptionaI[France]OptionaI[NotFound]

C\OptionaI[France]NotFound

DvFranceNotFound

答案:D

33.Giventhecodefragment:

Map<IntegerrInteger>mVal=newHashMapO();

10);

mVal.put(2,20);

//linenl

c.accept(lr2);

mVal?forEach(c);

WhichstatementcanbeinsertedintoIinen1toprint1,2;1,10;2,20;?

A、BiConsumerc=(i,j){System,out.print(i+"+j+";”);};

B、BiFunctionc=(i,j)->{System.out.print(i++j+";")};

GBiConsumerc=(i,j)->{System,out.print(i+"+j+

D\BiConsumerc=(i,j)->{System,out.print(i++j+

答案:A

34.Given:

publicclassFoo<KrV>{

privateKkey;

privateVvalue;

publicFoo(Kkey,Vvalue)(this.key=key;this.value=value;>

publicstatic<T>Foo<T,T>twice(Tvalue){returnnewFoo<T,T>(value,value)

publicKgetKey(){returnkey;}

publicVgetValue(){returnvalue;)

)

WhichoptionfaiIs?

A、Foomark=newFoo(uSteven,100);

B\Foopair=Foo.twice(uHeIIoWorId!n;

GFoopercentage=newFoo(uSteve,J,100);

D、Foograde=newFoo<>(uJohn,J,"A");

答案:C

35.Giventhecodefragment:

List<String>str=Arrays*asList("my","pen","is","your',"pen");

Predicate<String>test二s->{

inti=0;

booleanresult=s.contains("pen");

System.out.print(i++)+

returnresult;

);

str.stream()

.filter(test)

.findFirst()

.ifPresent(System.out::print);

Whatistheresu11?

A、0:0:pen

B、0:1:pen

C、0:0:0:0:0:pen

D、0:1:2:3:4:

E\ApiIationerroroccurs.

答案:A

36.GiventhestructureoftheSTUDENTtabIe:

Student(idINTEGER,nameVARCHAR)

Given:

staticConnectionnewConnection=null;

publicstaticConnectiongetDBConnection()throwsSQLException(

try(Connectioncon=DriveManager.getConnection(URLrusernamer

password)){

newConnection=con;

}

returnnewConnection;

J

publicstaticvoidmain(String[]args)throwsSQLException{

getDBConnection();

Statementst=newConnection.createStatement();

st.executeUpdate(''INSERTINTOstudentVALUES(102,,Kelvin')");

Assumethat:

TherequireddatabasedriverisconfiguredinthecIasspath.

TheappropriatedatabaseisaccessibIewiththellRL,userName,andpassWordexis

ts.

TheSQLqueryisvaIid.

Whatistheresu11?

AvTheprogramexecutessuccessfuIIyandtheSTUDENTtabIeisupdatedwithonere

cord.

B、TheprogramexecutessuccessfuIIyandtheSTUDENTtabIeisNOTupdatedwithan

yrecord.

C、ASQLExceptionisthrownasruntime.

DvANuIIPointerExceptionisthrownasruntime.

答案:c

37.Giventhecodefragment:

publicclassFoo{

publicstaticvoidmain(String[]args){

Map<IntegerrString>unsortMapnewHashMap<

unsortMap.put(10,V);

unsortMap.put(5,

unsortMap.put(lrW);

unsortMap.put(7r

unsortMap.put(50,*j*);

Map<IntegerrString〉treeMap=newTreeMap<IntegerrString>(new

Comparator<Integer>(){

^Overridepublicintcompare(IntegerolrIntegero2){return

pareTo

(ol);)));

treeMap.putAll(unsortMap);

for(Map.Entry

溫馨提示

  • 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論