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 101:

    Given the code fragment:

    public void infected() {

    System.out.print("before ");

    try {

    int i = 1/0;

    System.out.print("try ");

    } catch(Exception e) {

    System.out.print("catch ");

    throw e;

    } finally {

    System.out.print("finally ");

    }

    System.out.print("after ");

    }

    What is the result when infected() is invoked?

    A. before try catch finally after
    B. before catch finally after
    C. before catch after
    D. before catch finally
    E. before catch

  • Question 102:

    Which two are true about Singletons?

    A. A Singleton must implement serializable.
    B. A Singleton has only the default constructor.
    C. A Singleton implements a factory method.
    D. A Singleton improves a class's cohesion.
    E. Singletons can be designed to be thread-safe.

  • Question 103:

    Given the code fragment:

    public class Test {

    public static void main(String[] args) {

    Path dir = Paths.get("D:\\company");

    //insert code here. Line ***

    for (Path entry: stream) {

    System.out.println(entry.getFileName());

    }

    } catch (IOException e) {

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

    }

    }

    Which two try statements, when inserted at line ***, enable you to print files with the extensions.java, .htm, and .jar.

    A. try (DirectoryStream stream = Files.newDirectoryStream(dir, "*. {java, htm, jar}")) {
    B. try (DirectoryStream stream = Files.newDirectoryStream(dir, "*. [java, htm, jar]")) {
    C. try (DirectoryStream stream = Files.newDirectoryStream(dir, "*. {java*, htm*, jar*}")) {
    D. try (DirectoryStream stream = Files.newDirectoryStream(dir, "**. {java, htm, jar}")) {

  • Question 104:

    Given:

    class Erupt implements Runnable {

    public void run() {

    System.out.print(Thread.currentThread().getName());

    }

    }

    public class Yellowstone {

    static Erupt e = Erupt();

    Yellowstone() { new Thread(e, "const").start(); } // line A

    public static void main(String[] args) {

    new Yellowstone();

    new Faithful().go();

    }

    static class Faithful {

    void go() { new Thread(e, "inner").start(); } // line B

    }

    }

    What is the result?

    A. Both const and inner will be in the output.
    B. Only const will be in the output.
    C. Compilation fails due to an error on line A.
    D. Compilation fails due to an error on line B.
    E. An exception is thrown at runtime.

  • Question 105:

    Which four are syntactically correct?

    A. package abc; package def; import Java.util . * ; public class Test { }
    B. package abc; import Java.util.*; import Java.util.regex.* ; public class Test { }
    C. package abc; public class Test {} import Java.util.* ;
    D. import Java.util.*; package abc; public class Test {}
    E. package abc; import java.util. *; public class Test{}
    F. public class Test{} package abc; import java.util.*{}
    G. import java.util.*; public class Test{}
    H. package abc; public class test

  • Question 106:

    Given:

    interface Event {

    String getCategory();

    }

    public class CueSports {

    public String getCategory() {

    return "Cue sports";

    }

    }

    public class Snooker extends CueSports implements Event { // Line 9

    public static void main(String[] args) { Event obj1 = new Snooker(); // Line 11

    CueSports obj2 = new Snooker(); // Line 12

    System.out.print(obj1.GetCategory() + ", " + obj2.getCategory());

    }

    }

    What is the result?

    A. Cue sports, Cue sports
    B. Compilation fails at line 9
    C. Compilation fails at line 11
    D. Compilation fails at line 12
    E. Compilation fails at line 13

  • Question 107:

    Which is a key aspect of composition?

    A. Using inheritance
    B. Method delegation
    C. Creating abstract classes
    D. Implementing the composite interface

  • Question 108:

    Given the code fragment:

    public void otherMethod() {

    printFile("");

    }

    public void printFile(String file) {

    try (FileInputStream fis = new FileInputStream(file)) {

    System.out.println (fis.read());

    } catch (IOException e) {

    A. printStackTrace(); } Why is there no output when otherMethod is called?
    B. An exception other than IOException is thrown.
    C. Standard error is not mapped to the console.
    D. There is a compilation error.
    E. The exception is suppressed.

  • Question 109:

    Select four examples that initialize a NumberFormat reference using a factory.

    A. NumberFormat nf1 = new DecimalFormat();
    B. NumberFormat nf2 = new DecimalFormat("0.00") ;
    C. NumberFormat nf3 = NumberFormat.getInstance();
    D. NumberFormat nf4 = NumberFormat.getIntegerInstance();
    E. NumberFormat nf5 = DecimalFormat.getNumberInstance ();
    F. NumberFormat nf6 = Number Format.getCurrecyInstance () ;

  • Question 110:

    Given the existing destination file, a source file only 1000 bytes long, and the code fragment:

    public void process (String source, String destination) { try (InputStream fis = new FileInputStream(source); OutputStream fos = new FileOutputStream(destination)

    ) {

    byte [] buff = new byte[2014];

    int i;

    while ((i = fis.read(buff)) != -1) {

    fos.write(buff,0,i); // line ***

    }

    } catch (IOException e) {

    System.out.println(e.getClass());

    }

    }

    What is the result?

    A. Overrides the content of the destination file with the source file content
    B. Appends the content of the source file to the destination file after a new line
    C. Appends the content of the source file to the destination file without a break in the flow
    D. Throws a runtime exception at line ***

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.