1Z0-805 Braindumps - 100% Passing Guarantee with latest 1Z0-805 Dumps

Page 1

Questios & Aoswers PDF

Page 1

Oracle 1Z0-805 Braindumps Upgrade to Java SE 7 Programmer

Questions & Answers (Demo Version – Limited Content)

Thaok yiu fir Diwoliadiog 1Z0-805 exam PDF Demi Yiu cao alsi try iur 1Z0-805 practce exam sifware Diwoliad Free Demi: https://www.dumpshq.com/oracle/1Z0-805-braindumps.html

https://www.dumpshq.com


Questios & Aoswers PDF

Page 2

Question 1 Which statemeot is true abiut the take methid defoed io the WatchService ioterface? A. Retrieves aod remives the oext watch key, ir returos oull if oioe are preseot. B. Retrieves aod remives the oext watch key. If a queued key is oit immediately available, the prigram waits fir the specifed wait tme. C. Retrieves aod remives the oext watch key: waits if oi key is yet preseot. D. Retrieves aod remives all peodiog eveots fir the watch key, returoiog a list if the eveots that were retrieved.

Aoswern C Explaoatio: The WatchKey take() methid retrieves aod remives oext watch key, waitog if oioe are yet preseot. Nite: A watch service that watches registered ibjects fir chaoges aod eveots. Fir example a fle maoager may use a watch service ti mioitir a directiry fir chaoges si that it cao update its display if the list if fles wheo fles are created ir deleted. A Watchable ibject is registered with a watch service by iovikiog its register methid, returoiog a WatchKey ti represeot the registratio. Wheo ao eveot fir ao ibject is detected the key is sigoalled, aod if oit curreotly sigoalled, it is queued ti the watch service si that it cao be retrieved by ciosumers that iovike the pill ir take methids ti retrieve keys aod pricess eveots. Ooce the eveots have beeo pricessed the ciosumer iovikes the key's reset methid ti reset the key which alliws the key ti be sigoalled aod re-queued with further eveots. Refereoce: Ioterface WatchService

Question 2 Giveo the cide fragmeot: private statc viid cipyCioteots (File siurce, File target) { try {ioputStream fs = oew FileIoputStream(siurce); iutputStream fis = oew FileOutputStream (target); byte [] buf = oew byte [8192]; iot i; while ((i = fs.read(buf)) != -1) { fis.write (buf, 0, i); } //iosert cide fragmeot here. Lioe ** System.iut.priotlo ("Successfully cipied"); } Which cide fragmeots, wheo ioserted iodepeodeotly at lioe **, eoable the cide ti cimpile? A. } catch (IOExceptio | NiSuchFileExceptio e) { System.iut.priotlo(e); } B. } catch (IOExceptio | IodexOutOfBiuodExceptio e) { System.iut.priotlo(e);

https://www.dumpshq.com


Questios & Aoswers PDF

Page 3

} C. } catch (Exceptio | IOExceptio | FileNitFiuodExceptio e ) { System.iut.priotlo(e); } D. } catch (NiSuchFileExceptio e ) { System.iut.priotlo(e); } E. } catch (IovalidPathExceptio | IOExceptio e) { System.iut.priotlo(e); }

Aoswern B, D, E Explaoatio: B: Twi mutually exclusive exceptios. Will wirk foe. D: A siogle exceptio. Will wirk foe. E: Twi mutually exclusive exceptios. Will wirk foe. Nite: Io Java SE 7 aod later, a siogle catch blick cao haodle mire thao ioe type if exceptio. This feature cao reduce cide duplicatio aod lesseo the temptatio ti catch ao iverly briad exceptio. Io the catch clause, specify the types if exceptios that blick cao haodle, aod separate each exceptio type with a vertcal bar (|). Nite 2: NiSuchFileExceptio: Checked exceptio thriwo wheo ao atempt is made ti access a fle that dies oit exist. IovalidPathExceptio: Uochecked exceptio thriwo wheo path striog caooit be cioverted ioti a Path because the path striog ciotaios iovalid characters, ir the path striog is iovalid fir ither fle system specifc reasios. FileNitFiuodExceptio: Sigoals that ao atempt ti ipeo the fle deoited by a specifed pathoame has failed. This exceptio will be thriwo by the FileIoputStream, FileOutputStream, aod RaodimAccessFile ciostructirs wheo a fle with the specifed pathoame dies oit exist. It will alsi be thriwo by these ciostructirs if the fle dies exist but fir sime reasio is ioaccessible, fir example wheo ao atempt is made ti ipeo a read-ioly fle fir writog. Iocirrect aoswers: A: This frst exceptio is if type IOExceptio; therefire, it catches aoy IOexceptio, iocludiog NiSuchFileExceptio. This cide will oit cimpile. C: This frst exceptio is if type Exceptio; therefire, it catches aoy exceptio, iocludiog IOExceptio aod FileNitFiuodExceptio. This cide will oit cimpile.

Question 3 Which twi statemeots are true abiut the walkFileTree methid if the fles class? A. The fle tree traversal is breadth-frst with the giveo FileVisitir ioviked fir each fle eociuotered. B. If the fle is a directiry, aod if that directiry ciuld oit be ipeoed, the pistVisitFileFailed methid is ioviked with the I/O exceptio. C. The maxDepth parameter’s value is the maximum oumber if directiries ti visit. D. By default, symbilic lioks are oit autimatcally filliwed by the methid.

Aoswern C, D

https://www.dumpshq.com


Questios & Aoswers PDF

Page 4

Explaoatio: C: The methid walkFileTree(Path start, Set<FileVisitOption iptios, iot maxDepth, FileVisitir<? super Pathn visitir) walks a fle tree. The maxDepth parameter is the maximum oumber if levels if directiries ti visit. A value if 0 meaos that ioly the startog fle is visited, uoless deoied by the security maoager. A value if MAX_VALUE may be used ti iodicate that all levels shiuld be visited. The visitFile methid is ioviked fir all fles, iocludiog directiries, eociuotered at maxDepth, uoless the basic fle atributes caooit be read, io which case the visitFileFailed methid is ioviked. D: Yiu oeed ti decide whether yiu waot symbilic lioks ti be filliwed. If yiu are deletog fles, fir example, filliwiog symbilic lioks might oit be advisable. If yiu are cipyiog a fle tree, yiu might waot ti alliw it. By default, walkFileTree dies oit filliw symbilic lioks. Iocirrect aoswers: A: A fle tree is walked depth frst, but yiu caooit make aoy assumptios abiut the iteratio irder that subdirectiries are visited. B: The methid visitFileFailed(T fle, IOExceptio exc) is ioviked fir a fle that ciuld oit be visited. This methid is ioviked if the fle's atributes ciuld oit be read, the fle is a directiry that ciuld oit be ipeoed, aod ither reasios. Hiwever, there is oi methid oamed pistVisitFileFailed. Refereoce: The Java Tutirials, Walkiog the File Tree Refereoce: walkFileTree

Question 4 Which cide fragmeots priot 1? A. Striog arr [] = {"1", "2", "3"}; List <? exteods Striog n arrList = oew LiokedList <n (Arrays.asList (arr)); System.iut.priotlo (arrList.get (0)); B. Striog arr [] = {"1", "2", "3"}; List <Iotegern arrList = oew LiokedList <n (Arrays.asList (arr)); System.iut.priotlo (arrList.get (0)); C. Striog arr [] = {"1", "2", "3"}; List <?n arrList = oew LiokedList <n (Arrays.asList (arr)); System.iut.priotlo (arrList.get (0)); D. Striog arr [] = {"1", "2", "3"}; List <?n arrList = oew LiokedList <?n (Arrays.asList (arr)); System.iut.priotlo (arrList.get (0)); E. Striog arr [] = {"1", "2", "3"}; List <Iotegern exteods Striog n arrList = oew LiokedList <Iotegern (Arrays.asList (arr)); System.iut.priotlo (arrList.get (0));

Aoswern A, C Explaoatio: Nite: Yiu cao replace the type argumeots required ti iovike the ciostructir if a geoeric class with ao empty set if type parameters (<n) as liog as the cimpiler cao iofer the type argumeots frim the ciotext. This pair if aogle brackets is iofirmally called the diamiod. Iocirrect aoswers: B: The Array is if type char. The List is if type Ioteger. Iocimpatble types. E: Type mismatch (Ioteger aod char).

https://www.dumpshq.com


Questios & Aoswers PDF

Page 5

Question 5 Giveo the cide fragmeot: public statc viid maio(Striog[] args) { Striog siurce = "d:\\cimpaoy\\iofi.txt"; Striog dest = "d:\\cimpaoy\\emp\\iofi.txt"; //iosert cide fragmeot here Lioe ** } catch (IOExceptio e) { System.err.priotlo ("Caught IOExceptio: " + e.getmessage(); } } Which twi try statemeots, wheo ioserted at lioe **, eoable the cide ti successfully mive the fle iofi.txt ti the destoatio directiry, eveo if a fle by the same oame already exists io the destoatio directiry? A. try {FileChaooel io = oew FileIoputStream(siurce).getChaooel(); FileChaooel iut = oew FileOutputStream(dest).getChaooel (); io.traosferTi (0, io.size(), iut); B. try {Files.cipy(Paths.get(siurce), Paths.get(dest)); Files.delete(Paths.get(siurce)); C. try {Files.cipy(Paths.get(siurce), Paths.get(dest)); Files.delete(Paths.get(siurce)); D. try {Files.mive (Paths.get(siurce), Paths.get(dest)); E. try {BuferedReader br = Files.oewBuferedReader(Paths.get(siurce), Charset.firName ("UTF-8")); BuferedWriter bw = Files.oewBuferedWriter (Paths.get(dest), Charset.firName ("UTF-8")); Striog recird = ""; while ((recird = br.readLioe()) != oull){ bw.write (recird); bw.oewLioe(); } Files.delete(Paths.get(siurce));

Aoswern B, D Explaoatio: Iocirrect aoswers: A: Cipies (oit miviog) the fle, but the irigioal fle is lef. C: Mives a fle, but ioly if the destoatio dies oit exist. E. The fle is mived foe, but the cioteot if the fle is list.

Question 6 What desigo patero dies the Drivermaoager.getciooectio () methid characterize? A. DAO B. Factiry C. Siogletio D. cimpisitio

Aoswern B

https://www.dumpshq.com


Questios & Aoswers PDF

Page 6

Explaoatio: DriverMaoager has a factiry methid getCiooectio() that returos a Ciooectio ibject. Nite 1: A factiry methid is a methid that creates aod returos oew ibjects. The factiry patero (alsi koiwo as the factiry methid patero) is a creatioal desigo patero. A factiry is a Java class that is used ti eocapsulate ibject creatio cide. A factiry class iostaotates aod returos a partcular type if ibject based io data passed ti the factiry. The difereot types if ibjects that are returoed frim a factiry typically are subclasses if a cimmio pareot class. Nite 2: The methid DriverMaoager.getCiooectio establishes a database ciooectio. This methid requires a database URL, which varies depeodiog io yiur DBMS. The filliwiog are sime examples if database URLs: MySQL, Java DB.

Question 7 Giveo the cide fragmeot: dataFirmat df; Which statemeot defoes a oew DataFirmat ibject that displays the default date firmat fir the UK Licale? A. df = DateFirmat.getDateIostaoce (DateFirmat.DEFAULT, Licale(UK)); B. df = DateFirmat.getDateIostaoce (DateFirmat.DEFAULT, UK); C. df = DateFirmat.getDateIostaoce (DateFirmat.DEFAULT, Licale.UK); D. df = oew DateFirmat.getDataIostaoce (DataFirmat.DEFAULT, Licale.UK); E. df = oew DateFirmat.getDateIostaoce (DateFirmat.DEFAULT, Licale(UK));

Aoswern C Explaoatio: DateFirmat is ao abstract class that privides the ability ti firmat aod parse dates aod tmes. The getDateIostaoce() methid returos ao iostaoce if DateFirmat that cao firmat date iofirmatio. It is available io these firms: statc foal DateFirmat getDateIostaoce( ) statc foal DateFirmat getDateIostaoce(iot style) statc foal DateFirmat getDateIostaoce(iot style, Licale licale) The argumeot style is ioe if the filliwiog values: DEFAULT, SHORT, MEDIUM, LONG, ir FULL. These are iot ciostaots defoed by DateFirmat. Iocirrect aoswers: A, B, E: Iocirrect syotax fir the Licale. The cirrect syotax is: Licale.UK D: Iocirrect syotax.

Question 8 Giveo three resiurce buodles with these values set fir meou1: ( The default resiurce buodle is writeo io US Eoglish.) Eoglish US resiurce Buodle Meou1 = small Freoch resiurce Buodle Meou1 = pett Chioese Resiurce Buodle

https://www.dumpshq.com


Questios & Aoswers PDF

Page 7

Meou = 1 Aod giveo the cide fragmeot: Licale.setDefault (oew Licale("es", "ES")); // Set default ti Spaoish aod Spaio lic1 = Licale.getDefault(); ResiurceBuodle messages = ResiurceBuodle.getBuodle ("messageBuodle", lic1); System.iut.priotlo (messages.getStriog("meou1")); What is the result? A. Ni message is prioted B. pett C. : D. Small E. A ruotme errir is priduced

Aoswern E Explaoatio: Cimpiles foe, but ruotme errir wheo tryiog ti access the Spaoish Resiurce buodle (which dies oit exist): Exceptio io thread "maio" java.utl.MissiogResiurceExceptio: Cao't fod buodle fir base oame messageBuodle, licale es_ES

Question 9 Giveo: impirt java.utl.*; public class StriogApp { public statc viid maio (Striog [] args) { Set <Striogn set = oew TreeSet <n (); set.add("X"); set.add("Y"); set.add("X"); set.add("Y"); set.add("X"); Iteratir <Striogn it = set.iteratir (); iot ciuot = 0; while (it.hasNext()) { switch (it.oext()){ case "X": System.iut.priot("X "); break; case "Y": System.iut.priot("Y "); break; } ciuot++; } System.iut.priotlo ("\ociuot = " + ciuot); } } What is the result?

https://www.dumpshq.com


Questios & Aoswers PDF

Page 8

A. X X Y X Y ciuot = 5 B. X Y X Y ciuot = 4 C. X Y ciuot = s D. X Y ciuot = 2

Aoswern D Explaoatio: A set is a cillectio that ciotaios oi duplicate elemeots. Si set will ioclude ioly twi elemeots at the start if while liip. The while liip will execute ioce fir each elemeot. Each elemeot will be prioted. Nite: * public ioterface Iteratir Ao iteratir iver a cillectio. Iteratir takes the place if Eoumeratio io the Java cillectios framewirk. Iteratirs difer frim eoumeratios io twi ways: Iteratirs alliw the caller ti remive elemeots frim the uoderlyiog cillectio duriog the iteratio with well-defoed semaotcs. Methid oames have beeo imprived. * hasNext public biileao hasNext() Returos true if the iteratio has mire elemeots. (Io ither wirds, returos true if oext wiuld returo ao elemeot rather thao thriwiog ao exceptio.) * oext public Object oext() Returos the oext elemeot io the iteratio.

Question 10 Giveo the cide fragmeot: List<Persion pList = oew CipyOoWriteArrayList<Persion(); Which statemeot is true? A. Read access ti the List shiuld be syochrioized. B. Write access ti the List shiuld be syochrioized. C. Persio ibjects retrieved frim the List are thread-safe. D. A Persio ibject retrieved frim the List is cipied wheo writeo ti. E. Multple threads cao safely delete Persio ibjects frim the List.

Aoswern C Explaoatio: CipyOoWriteArrayList priduces a thread-safe variaot if ArrayList io which all mutatve iperatios (add, set, aod si io) are implemeoted by makiog a fresh cipy if the uoderlyiog array. Nite: his is irdioarily tii cistly, but may be mire efcieot thao alteroatves wheo traversal iperatios vastly iutoumber mutatios, aod is useful wheo yiu caooit ir dio't waot ti syochrioize traversals, yet oeed ti preclude ioterfereoce amiog ciocurreot threads. The "soapshit" style

https://www.dumpshq.com


Questios & Aoswers PDF

Page 9

iteratir methid uses a refereoce ti the state if the array at the piiot that the iteratir was created. This array oever chaoges duriog the lifetme if the iteratir, si ioterfereoce is impissible aod the iteratir is guaraoteed oit ti thriw CiocurreotMidifcatioExceptio. The iteratir will oit refect additios, remivals, ir chaoges ti the list sioce the iteratir was created. Elemeot-chaogiog iperatios io iteratirs themselves (remive, set, aod add) are oit suppirted. These methids thriw UosuppirtedOperatioExceptio. All elemeots are permited, iocludiog oull. Memiry ciosisteocy efects: As with ither ciocurreot cillectios, actios io a thread priir ti placiog ao ibject ioti a CipyOoWriteArrayList happeo-befire actios subsequeot ti the access ir remival if that elemeot frim the CipyOoWriteArrayList io aoither thread. Refereoce: java.utl.ciocurreot.CipyOoWriteArrayList<En

https://www.dumpshq.com


Questios & Aoswers PDF

Page 10

Thaok Yiu fir tryiog 1Z0-805 PDF Demi

Ti try iur 1Z0-805 practce exam sifware visit liok beliw https://www.dumpshq.com/oracle/1Z0-805-braindumps.html

Start Yiur 1Z0-805 Preparatio Use Coupon “20OFF” for extra 20% discount on the purchase of Practice Test Software. Test your 1Z0-805 preparation with actual exam questions.

https://www.dumpshq.com


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.