[Free] 2018(Jan) EnsurePass Examcollection Oracle 1z0-804 Dumps with VCE and PDF 51-60

Ensurepass.com : Ensure you pass the IT Exams
2018 Jan Oracle Official New Released 1z0-804
100% Free Download! 100% Pass Guaranteed!
http://www.EnsurePass.com/1z0-804.html

Java SE 7 Programmer II

Question No: 51

Given the code fragment:

Ensurepass 2018 PDF and VCE

If the file userguide.txt does not exist, what is the result?

  1. An empty file iscreated and success is printed

  2. class java.io.FileNotFoundException

  3. class java.io.IOException

  4. class java.lang.Exception

  5. Compilation fails

Answer: E Explanation:

Compilation fails : Exception Exception is not compatible with throws clause in Base.process() IOExceptiondie Exception in der Derived Class Methode muss zur Base Class Methode passen.

Question No: 52

Given that myFile.txt contains:

Ensurepass 2018 PDF and VCE

What is the result?

  1. 1: First 2: Second 3: Third

  2. 1: First 2: Second

    3: First

  3. 1: First 2: First

    3: First

  4. IOExcepton

  5. Compilation fails

Answer: B Explanation:

BufferedReader: mark() : Marks the present position in the stream. Subsequent calls to reset() will attempt toreposition the stream to this point.

reset() : Resets the stream to the most recent mark.

!! After last Line is read (readLine()), a trial to reset() throws IOException : Mark invalid

Question No: 53

Given the code fragment:

Ensurepass 2018 PDF and VCE

Which code fragment inserted at line ***, enables the code to compile?

  1. public void process () throws FileNotFoundException, IOException { super.process (); while ((record = br.readLine()) !=null) {

    System.out.println(record);

    }}

  2. public void process () throws IOException { super.process ();

    while ((record = br.readLine()) != null) { System.out.println(record);

    }}

  3. public void process () throws Exception { super.process ();

    while ((record = br.readLine()) !=null) { System.out.println(record);

    }}

  4. public void process (){ try {

    super.process ();

    while ((record = br.readLine()) !=null) { System.out.println(record);

    }

    } catch (IOException | FileNotFoundException e) { }

    }

  5. public void process (){ try {

super.process ();

while ((record = br.readLine()) !=null) { System.out.println(record);

}

} catch (IOException e) {}

}

Answer: E Explanation:

A: Compilation fails: Exception IOException is not compatible with throws clause in Base.process()

B: Compilation fails: Exception IOException is not compatible with throws clause in Base.process()

C: Compilation fails: Exception Exception is not compatible with throws clause in Base.process()

D: Compilation fails: Exception FileNotFoundException has already been caught by the alternative IOException

Alternatives in a multi-catch statement cannot be related to subclassing Alternative java.io.FileNotFoundException is a subclass of alternative java.io.IOException

E: compiles …

Question No: 54

Given the code fragment:

Ensurepass 2018 PDF and VCE

Why is there no output when otherMethod is called?

  1. An exception other than IOException is thrown.

  2. Standard error is not mapped to the console.

  3. There is a compilation error.

  4. The exception is suppressed.

Answer: C Explanation:

C: wenn printStackTrace() ohne Referenz auf das Exception object aufgerufen A : java.io.FileNotFoundException: wenn e.printStackTrace();

The code compiles fine The line

FileInputStream fis = new FileInputStream(file)) will fail at runtime since file is an empty string. Note:

public void printStackTrace()

Prints this throwable and its backtrace to the standard error stream.

Question No: 55

Given that myfile.txt contains:

Ensurepass 2018 PDF and VCE

What is the result?

  1. new file.txt contains: 1: First

    2: Second

    3: Third

  2. new file.txt contains:

    1: First 2: Second 3: Third

  3. newfile.txt is empty

  4. an exception is thrown at runtime

  5. compilation fails

Answer: A

Explanation:

For each line in the file myfile.text the line number and the line is written into newfile.txt.

Question No: 56

Given:

Ensurepass 2018 PDF and VCE

What is the result?

  1. false

    \sales\quarter\ . . \qtrlreport.txt

  2. false

    \quarter\ . . \qtrlreport.txt

  3. true

    . . \ . . \ . . \ annualreport.txt

  4. true

\ . . \ . . \annualreport.txt

Answer: A

Explanation:

( richtig !! import java.nio.file.Path; import java.nio.file.Paths; ) original-Aufgabe war ( falsch

gt;gt;

import java.io.file.Path; import java.io.file.Paths; )

The relativize method that can be used to construct a relative path between two paths. relativize

Path relativize(Path other)

Constructs a relative path between this path and a given path. Parameters:other – the path to relativize against this path

Returns:the resulting relative path, or an empty path if both paths are equal Note:

Relativization is the inverse of resolution. This method attempts to construct a relative path that when resolvedagainst this path, yields a path that locates the same file as the given path. For18example, on UNIX, if this path is quot;/a/bquot; and the given path is quot;/a/b/c/dquot; then the resulting relative path would bequot;c/dquot;. Where this path and the given path do not have a root component, then a relative path can beconstructed. A relative path cannot be constructed if only one of the paths have a root component. Where bothpaths have a root component then it is implementation dependent if a relative path can be constructed. If thispath and the given path are equal then an empty path is returned.

For any two normalized paths p and q, where q does not have a root component,p.relativize(p.resolve(q)).equals(q)

When symbolic links are supported, then whether the resulting path, when resolved against this path, yields apath that can be used to locate the same file as other is implementation dependent. For example, if this path isquot;/a/bquot; and the given path is quot;/a/xquot; then the resulting relative path may be quot;../xquot;. If quot;bquot; is a symbolic link then isimplementation dependent if quot;a/b/../xquot; would locate the same file as quot;/a/xquot;.

Question No: 57

Given the code fragment:

Ensurepass 2018 PDF and VCE

Which two try statements, when inserted at line ***, enable the code to successfully move the file info.txt to thedestination directory, even if a file by the same name already exists in the destination directory?

  1. try (FileChannel in = new FileInputStream (source). getChannel(); FileChannel out = new FileOutputStream

    (dest).getChannel()) { in.transferTo(0, in.size(), out);

  2. try ( Files.copy(Paths.get(source),Paths.get(dest)); Files.delete (Paths.get(source));

  3. try ( Files.copy(Paths.get(source), Paths.get(dest),StandardCopyOption.REPLACE_EXISTING); Files.delete (Paths.get(source));

  4. try (Files.move(Paths.get(source),Paths.get(dest));

  5. try(BufferedReader br = Files.newBufferedReader(Paths.get(source), Charset.forName(quot;UTF- 8quot;));

BufferedWriter bw = Files.newBufferedWriter(Paths.get(dest), Charset.forName(quot;UTF-8quot;)); String record =

quot;quot;;

while ((record = br.readLine()) ! = null) { bw.write(record);

bw.newLine();

}

Files.delete(Paths.get(source));

Answer: C,E Explanation:

A: copies only, don’t move operation

B,C,D (no try-with-resource !) syntax change to: try { … B: throws FileAlreadyExistsException

C: correct if syntax change to : StandardCopyOption.REPLACE_EXISTING (before

REPLACE_Existing)

D: throws FileAlreadyExistsException

E: works properly if the sourcefile has the correct format, utf-8 here (else throws MalformedInputException)

AND syntax is corrected to:

try ( BufferedReader br = Files.newBufferedReader(Paths.get(source), Charset.forName(“UTF-8));

BufferedWriter bw = Files.newBufferedWriter(Paths.get(dest), Charset.forName(“UTF-8));

){

String record = “”;

…..

Question No: 58

The default file system includes a logFiles directory that contains the following files:

Log-Jan 2009 log_0l_20l0 log_Feb20l0 log_Feb2011 log_10.2012 log-sum-2012

How many files does the matcher in this fragment match?

PathMatcher matcher = FileSystems.getDefault ().getPathMatcher (quot;glob: *???_*1?quot; );

  1. One

  2. Two

  3. Three

  4. Four

  5. Five

  6. Six

Answer: B Explanation:

The pattern to match is *???_*1? (regex quot;.*…_.*1.quot;)

This means at least three characters before the symbol _ , followed by any amount of characters. The next tolast character must be 1. The last character can by any character. The following file names match this pattern:

log_Feb2011 log_10.2012 Trap !! l is not 1 !!

Question No: 59

Given the following files in doc directory:

  • Index.htm

  • Service.html

  • Logo.gif

  • Title.jpg

And the code fragment:

Ensurepass 2018 PDF and VCE

What is the result, if doc is present in the current directory?

  1. No output is produced.

  2. index.htm

  3. index.htm userguide.txt logo.gif

  4. index.htm service.html userguide.txt logo.gif

Answer: A Explanation:

The Glob search expression is defined through quot;glob:*.htm, html, xmlquot; The correct answer is A

The glob is trying to match all the string. The correct way is glob:*.{htm,html,xml}

and then would be found: Index.htm

Service.html

Question No: 60

Which code fragment correctly appends quot;Java 7quot; to the end of the file /tmp/msg.txt?

  1. FileWriter w = new FileWriter(quot;/tmp/msg.txtquot;); append(quot;Java 7quot;);

    close();

  2. FileWriter w = new FileWriter(quot;/tmp/msg.txtquot;, true); append(quot;Java 7quot;);

    close();

  3. FileWriter w = new FileWriter(quot;/tmp/msg.txtquot;, FileWriter.MODE_APPEND); append(quot;Java 7quot;);

    close();

  4. FileWriter w = new FileWriter(quot;/tmp/msg.txtquot;, Writer.MODE_APPEND); append(quot;Java 7quot;);

close();

Answer: B Explanation:

FileWriter(File file, boolean append) A: clears the file and append quot;Java7quot;

Constructs a FileWriter object given a File object.

If the second argument is true, then bytes will be written to the end of the file rather than the beginning.Parameters:

file – a File object to write toappend – if true, then bytes will be written to the end of the file rather than the beginning

100% Ensurepass Free Download!
Download Free Demo:1z0-804 Demo PDF
100% Ensurepass Free Guaranteed!
Download 2018 EnsurePass 1z0-804 Full Exam PDF and VCE

EnsurePass ExamCollection Testking
Lowest Price Guarantee Yes No No
Up-to-Dated Yes No No
Real Questions Yes No No
Explanation Yes No No
PDF VCE Yes No No
Free VCE Simulator Yes No No
Instant Download Yes No No

Leave a Comment

(0 Comments)

Your email address will not be published. Required fields are marked *