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

    Which statement creates a low overhead, low-contention random number generator that is isolated to thread to generate a random number between 1 and 100?

    A. int i = ThreadLocalRandom.current().nextInt(1, 101);
    B. int i = ThreadSafeRandom.current().nextInt(1, 101);
    C. int i = (int) Math.random()*100+1;
    D. int i = (int) Math.random(1, 101);
    E. int i = new random().nextInt(100)+1;

  • Question 72:

    Given:

    import java.util.regex.Matcher;

    import java.util.regex.Pattern;

    public class Test {

    private static String REGEX = "\\Sto\\S|\\bo\\b";

    private static String INPUT = "Nice to see you,to,be fine.";

    private static String REPLACE =",";

    public static void main(String[] args) {

    Pattern p = Pattern.compile(REGEX);

    Matcher m = p.matcher(INPUT);

    INPUT = m.replaceAll(REPLACE);

    System.out.println(INPUT);

    }

    }

    What is the result?

    A. Nice to see you, be fine
    B. Nice, see you, be fine
    C. Nice, see you, to, be fine
    D. Nice, see you, be fine
    E. Nice to see y, u, be fine

  • Question 73:

    Given the fragment:

    public class CustomerApplication {

    public static void main (String args[]) {

    CustomerDAO custDao= new CustomerDAOMemoryImpl(); // Line 3

    // ... other methods

    } }

    Which two valid alternatives to line 3 would decouple this application from a specific implementation of CustomerDAO?

    A. CustomerDAO custDao = CustomerDAO();
    B. CustomerDAO custDao = (CustomerDAO) new Object ();
    C. CustomerDAO custDao = CustomerDAO.getInstance();
    D. CustomerDAO custDao = (CustomerDAO) new CustomerDAOmemoryImp1();
    E. CustomerDAO custDao = customerDAOFactory.getInstance();

  • Question 74:

    Given the code fragment:

    What change should you make to apply good coding practices to this fragment?

    A. Add nested try-with-resources statements for the statement and Resulset declarations.
    B. Add the statement and Resulset declarations to the cry-with-resources statement.
    C. Add a finally clause after the catch clause.
    D. Rethrow SQLException.

  • Question 75:

    Given:

    import java.util.*;

    public class AccessTest {

    public static void main(String[] args) {

    Thread t1 = new Thread(new WorkerThread());

    Thread t2 = new Thread(new WorkerThread());

    t1.start(); t2.start; // line1

    }

    }

    class WorkPool {

    static ArrayList list = new ArrayList<>(); // line2

    public static void addItem() { // line3

    list.add(1); // Line4

    }

    }

    class WorkerThread implements Runnable {

    static Object bar = new Object ();

    public void run() { //line5

    for (int i=0; i<5000;i++) WorkPool.addItem(); // line6

    }

    }

    Which of the four are valid modifications to synchronize access to the valid list between threads t1 and t2?

    A. Replace line 1 with: Synchronized (t2) (t1.start();) synchronized(t1) (t2.start();)
    B. Replace Line 2 with: static CopyWriteArrayList list = new CopyWriteArrayList();
    C. Replace line 3 with: synchronized public static void addItem () {
    D. Replace line 4 with: synchronized (list) (list.add(1);)
    E. Replace line 5 with: Synchronized public void run () {
    F. replace line 6 with: Synchronized (this) {for (in i = 0, i
    G. Replace line 6 with: synchronized (bar) {for (int i= 0; i

  • Question 76:

    Give:

    Class Employee {

    public int checkEmail() {/* . . . */}

    public void sendEmail (String email) {/* . . . */}

    public Boolean validDateEmail(){/* . . . */}

    public void printLetter (String letter) {/* . . . */} }

    Which is correct?

    A. Employee takes advantage of composition.
    B. Employee "has-an" Email.
    C. Employee "is-a" LetterPrinter.
    D. Employee has low cohesion.

  • Question 77:

    Given:

    public class Task {

    String title;

    static class Counter {

    int counter = 0;

    void increment() {counter++}

    }

    public static void main(String[] args) {

    // insert code here

    }

    }

    Which statement, inserted at line 8, enables the code to compile?

    A. new Task().new Counter().increment();
    B. new Task().Counter().increment();
    C. new Task.Counter().increment();
    D. Task.Counter().increment();
    E. Task.Counter.increment();

  • Question 78:

    Given the directory structure that contains three directories: company, Salesdat, and Finance:

    Company

    And the code fragment:

    If Company is the current directory, what is the result?

    A. Prints only Annual.dat
    B. Prints only Salesdat, Annual.dat
    C. Prints only Annual.dat, Salary.dat, Target.dat
    D. Prints at least Salesdat, Annual.dat, Salary.dat, Target.dat

  • Question 79:

    When using the default file system provider with a JVM running on a DOS-based file system, which statement is true?

    A. DOS file attributes can be read as a set in a single method call.
    B. DOS file attributes can be changed as a set in a single method call.
    C. DOS file attributes can be modified for symbolic links and regular files.
    D. DOS file attributes can be modified in the same method that creates the file.

  • Question 80:

    Which class safely protects the doIt () method from concurrent thread access?

    A. class SafeMethod { Static int ID = 0; Public static void doIt(String s) { Synchronized (s) { System.out.println("Name: " + s + " ID: " + id++); } } }
    B. class SafeMethod { Static int ID = 0; Public static void doIt(String s) { Synchronized (new object () ) { System.out.println("Name: " + s + " ID: " + id++); } } }
    C. class SafeMethod { Static int ID = 0; Public static void doIt(String s) { Synchronized (this) { System.out.println("Name: " + s + " ID: " + id++); } } }
    D. class SafeMethod { Static int ID = 0; Public static void doIt(String s) { Synchronized (SafeMethod.class) { System.out.println("Name: " + s + " ID: " + id++); } } }

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.