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

    Given:

    public class CowArray extends Thread {

    static List myList = new CopyOnWriteArrayList();

    public static void main(String[] args) {

    myList.add(11);

    myList.add(22);

    myList.add(33);

    myList.add(44);

    new CowArray().start();

    for(Integer i: myList) {

    try { Thread.sleep(1000); }

    catch (Exception e) { System.out.print("e1 "); }

    System.out.print(" " +i);

    }

    }

    public void run() {

    try { Thread.sleep(500); }

    catch (Exception e) { System.out.print("e2 "); }

    myList.add(77);

    System.out.print("size: " + myList.size() + ", elements:");

    }

    }

    What is the most likely result?

    A. size: 4, elements: 11 22 33 44
    B. size: 5, elements: 11 22 33 44
    C. size: 4, elements: 11 22 33 44 77
    D. size: 5, elements: 11 22 33 44 77
    E. a ConcurrentModification Exception is thrown

  • Question 2:

    Given these facts about Java classes in an application:

    -

    Class X is-a Class SuperX.

    -

    Class SuperX has-a public reference to a Class Z.

    -

    Class Y invokes public methods in Class Util.

    -

    Class X uses public variables in Class Util.

    Which three statements are true?

    A. Class X has-a Class Z.
    B. Class Util has weak encapsulation.
    C. Class Y demonstrates high cohesion.
    D. Class X is loosely coupled to Class Util.
    E. Class SuperX's level of cohesion CANNOT be determined

  • Question 3:

    Given the code fragment:

    public static void main(String[] args) {

    String source ="d:\\company\\info.txt";

    String dest ="d:\\company\\emp\\info.txt";

    // insert code fragment here. Line ***

    } catch (IOException e) {

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

    }

    }

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

    the destination directory?

    A. try (FileChannel in = new FileInputStream (source). getChannel(); FileChannel out = new FileOutputStream(dest).getChannel()) { in.transferTo(0, in.size(), out);
    B. try (Files.copy(Paths.get(source),Paths.get(dest)); Files.delete (Paths.get(source));
    C. try (Files.copy(Paths.get(source), Paths.get(dest),StandardCopyOption.REPLACE_Existing); Files.delete(Paths.get(source));
    D. try (Files.move(Paths.get(source), Paths.get(dest));
    E. 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 = ""; while ((record = br.readLine()) ! = null) { bw.write(record); bw.newLine(); } Files.delete(Paths.get(source));

  • Question 4:

    Given the code format:

    SimpleDateFormat sdf;

    Which code statements will display the full text month name?

    A. sdf = new SimpleDateFormat ("mm", Locale.UK); System.out.println("Result: ", sdf.format(new date()));
    B. sdf = new SimpleDateFormat ("MM", Locale.UK); System.out.println("Result: ", sdf.format(new date()));
    C. sdf = new SimpleDateFormat ("MMM", Locale.UK); System.out.println("Result: ", sdf.format(new date()));
    D. sdf = new SimpleDateFormat ("MMMM", Locale.UK); System.out.println("Result: ", sdf.format(new date()));

  • Question 5:

    Which two properly implement a Singleton pattern?

    A. class Singleton { private static Singleton instance; private Singleton () {} public static synchronized Singleton getInstance() { if (instance = = null) { instance = new Singleton (); } return instance; } }
    B. class Singleton { private static Singleton instance = new Singleton(); protected Singleton () {} public static Singleton getInstance () { return Instance; } }
    C. class Singleton { Singleton () {} private static class SingletonHolder { private static final Singleton INSTANCE = new Singleton (); } public static Singleton getInstance () { return SingletonHolder.INSTANCE; } }
    D. enum Singleton { INSTANCE; }

  • Question 6:

    Given the code fragment:

    public class Rank {

    static CopyOnWriteArraySet arr = new CopyOnWriteArraySet<>();

    static void verify() {

    String var ="";

    Iterator e=arr.iterator();

    while (e.hasNext()) {

    var = e.next();

    if(var.equals("A"))

    arr.remove(var);

    }

    }

    public static void main (String[] args) {

    ArrayList list1 = new ArrayList<>();

    list1.add("A"); list1.add("B");

    ArrayList list2 = new ArrayList<>();

    list1.add("A"); list1.add("D");

    arr.addAll(list1);

    arr.addAll(list2);

    verify();

    for(String var : arr)

    System.out.print(var + " ");

    }

    }

    What is the result?

    A. Null B D
    B. Null B null D
    C. B D
    D. D
    E. An exception is thrown at runtime

  • Question 7:

    Given the following incorrect program:

    Which two changes make the program work correctly?

    A. Results must be retrieved from the newly created MyTask instances and combined.
    B. The threshold value must be increased so that the overhead of task creation does not dominate the cost of computation.
    C. The midpoint computation must be altered so that it splits the workload in an optimal manner.
    D. The compute () method must be changed to return an Integer result.
    E. The compute () method must be enhanced to (fork) newly created tasks.
    F. The myTask class must be modified to extend RecursiveAction instead of RecursiveTask

  • Question 8:

    Which two code blocks correctly initialize a Locale variable?

    A. Locale loc1 = "UK";
    B. Locale loc2 = Locale.getInstance("ru");
    C. Locale loc3 = Locale.getLocaleFactory("RU");
    D. Locale loc4 = Locale.UK;
    E. Locale loc5 = new Locale("ru", "RU");

  • Question 9:

    Given:

    Which three are true?

    A. BasicCar uses composition.
    B. SuperCar uses composition.
    C. BasicCar is-a Car.
    D. SuperCar is-a Car.
    E. SuperCar takes advantage of polymorphism
    F. BasicCar has-a Car

  • Question 10:

    Given the interface:

    Public interface Idgenerator {

    int getNextId();

    }

    Which class implements IdGenerator in a thread-safe manner, so that no threads can get a duplicate id value current access?

    A. Public class generator Implements IdGenerator { Private AtomicInteger id = new AtomicInteger (0); return id.incrementAndget(); } }
    B. Public class Generator Implements idGenerator { private int id = 0; return ++id; } }
    C. Public class Generator Implements IdGenerator { private volatile int Id = 0; return + + Id; }
    D. Public class Generator Implements IdGenerator { private int id = 0; public int getNextId() { synchronized (new Generator()) { return + + id; } } }
    E. Public class Generator Implements IdGenerator { private int id = 0; public int getnextId() { synchronized (id) { return + + 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.