1Z0-804 Exam Details

  • Exam Code
    :1Z0-804
  • Exam Name
    :Java SE 7 Programmer II
  • Certification
    :Oracle Certifications
  • Vendor
    :Oracle
  • Total Questions
    :150 Q&As
  • Last Updated
    :Dec 08, 2021

Oracle 1Z0-804 Online Questions & Answers

  • Question 121:

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

    A. Filewriter w = new FileWriter("/tmp/msg.txt");
    B. append("Java 7");
    C. close();
    D. Filewriter w = new FileWriter("/tmp/msg.txt", true);
    E. append("Java 7");
    F. close();
    G. Filewriter w = new FileWriter("/tmp/msg.txt", FileWriter.MODE_APPEND);
    H. append("Java 7");
    I. close();
    J. Filewriter w = new FileWriter("/tmp/msg.txt", Writer.MODE_APPEND);

  • Question 122:

    Given the code fragment:

    What is the result, if the file salesreport.dat does not exist?

    A. Compilation fails only at line 6
    B. Compilation fails only at line 13
    C. Compilation fails at line 6 and 13
    D. Class java.io.IOException
    E. Class java.io.FileNotFoundException

  • Question 123:

    Given the code fragment:

    1.

    path file = path.get (args.[0])

    2.

    try {

    3.

    } / / statements here

    4.

    catch (IOException) i ) {

    5.

    }

    And a DOS-based file system:

    Which option, containing statement(s), inserted at line 3, creates the file and sets its attributes to hidden and read-only?

    A. DOSFileAttributes attrs = Files.setAttribute(file, "dos:hidden", "dos: readonly") Files.createFile(file, attrs)
    B. Files.craeteFile(file); Files.setAttribute(file, "dos:hidden", "dos:readonly");
    C. Files.createFile(file, "dos:hidden", "dos:readonly");
    D. Files.createFile(file); Files.setAttribute(file, "dos:hidden", true); Files.setAttribute(file, "dos:readonly", true);

  • Question 124:

    Given the following code fragment:

    10.

    p1 = paths.get("report.txt");

    11.

    p2 = paths.get("company");

    12.

    / / insert code here

    Which code fragment, when inserted independently at line 12, move the report.txt file to the company directory, at the same level, replacing the file if it already exists?

    A. Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
    B. Files.move(p1, p2, StandardCopyOption.REPLACE_Existing, LinkOption.NOFOLLOW_LINKS);
    C. Files.move (p1, p2, StandardCopyOption.REPLACE_EXISTING, LinkOption.NOFOLLOW_LINKS);
    D. Files.move(p1, p2, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.copy_ATTRIBUTES, StandrardCopyOp)
    E. Files.move (p1, p2 StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.copy_ATTRIBUTES, LinkOption.NOF)

  • Question 125:

    Given the fragment:

    If thread a and thread b are running, but not completing, which two could be occurring?

    A. livelock
    B. deadlock
    C. starvation
    D. loose coupling
    E. cohesion

  • Question 126:

    Which concept allows generic collections to interoperate with java code that defines collections that use raw types?

    A. bytocode manipulation
    B. casting
    C. autoboxing
    D. auto-unboxing
    E. type erasure

  • Question 127:

    Given:

    public class Print01 {

    public static void main(String[] args) {

    double price = 24.99;

    int quantity = 2;

    String color = "Blue";

    // insert code here. Line ***

    }

    }

    Which two statements, inserted independently at line ***, enable the program to produce the following output:

    We have 002 Blue pants that cost $24.99.

    A. System.out.printf("We have %03d %s pants that cost $%3.2f.\n", quantity, color, price);
    B. System.out.printf("We have $03d $s pants that cost $$3.2f.\n", quantity, color, price);
    C. String out = String.format ("We have %03d %s pants that cost $%3.2f.\n", quantity, color, price); System.out.println(out);
    D. String out = System.out.format("We have %03d %s pants that cost $%3.2f.", quantity, color, price); System.out.println(out);
    E. System.out.format("We have %s %s pants that cost $%s.\n", quantity, color, price);

  • Question 128:

    Given that myfile.txt contains:

    First

    Second

    Third

    Given the following code fragment:

    public class ReadFile02 {

    public static void main(String[] args) {

    String fileName1 = "myfile.txt";

    String fileName2 = "newfile.txt";

    try (BufferedReader buffIn =

    new BufferedReader(new FileReader(fileName1));

    BufferedWriter buffOut =

    new BufferedWriter(new FileWriter(fileName2))

    ) {

    String line = ""; int count = 1;

    line = buffIn.readLine();

    while (line != null) {

    buffOut.write(count + ": " + line);

    buffOut.newLine();

    count++;

    line = buffIn.readLine();

    }

    } catch (IOException e) {

    System.out.println("Exception: " + e.getMessage());

    }

    }

    }

    What is the result?

    A. new file.txt contains: 1: First 2: Second 3: Third
    B. new file.txt contains: 1: First 2: Second 3: Third
    C. newfile.txt is empty
    D. an exception is thrown at runtime
    E. compilation fails

  • Question 129:

    Given the code fragment:

    public class IsContentSame {

    public static boolean isContentSame() throws IOException {

    Path p1=Paths.get("D:\\faculty\\report.txt");

    Path p2=Paths.get("C:\\student\\report.txt");

    Files.copy(p1,p2,StandardCopyOption.REPLACE_EXISTING,StandardCopyOption.COPY_

    ATTRIBUTES,LinkOption.NOFOLLOW_LINKS);

    if(Files.isSameFile(p1,p2)) {

    return true;

    } else {

    return false;

    }

    }

    public static void main(String[] args) {

    try {

    boolean flag = isContentSame();

    if(flag)

    System.out.println("Equal");

    else

    System.out.println("Not equal");

    } catch (IOException e) {

    System.err.println("Caught IOException: " + e.getMessage());

    }

    }

    }

    What is the result when the result.txt file already exists in c:\student?

    A. The program replaces the file contents and the file's attributes and prints Equal.
    B. The program replaces the file contents as well as the file attributes and prints Not equal.
    C. An unsupportedoperationException is thrown at runtime.
    D. The program replaces only the file attributes and prints Not equal.

  • Question 130:

    Given the following files in doc directory: And the code fragment:

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

    A. No output is produced.
    B. index.htm
    C. index.htm userguide.txt logo.gif
    D. index.htm service.html userguide.txt logo.gif

Tips on How to Prepare for the Exams

Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only Oracle exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your 1Z0-804 exam preparations and Oracle certification application, do not hesitate to visit our Vcedump.com to find your solutions here.