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

    Assuming the port statements are correct, which two code fragments create a one-byte file?

    A. OutputStream fos = new FileOutputStream(new File("/tmp/data.bin")); OutputStream bos = new BufferedOutputStream(fos); DataOutputStream dos = new DataOutputStream(bos); dos.writeByte(0); dos.close();
    B. OutputStream fos = new FileOutputStream ("/tmp/data.bin"); dataOutputStream dos = new DataOutputStream(fos); dos.writeByte(0); dos.close();
    C. OutputStream fos = new FileOutputStream (new File ("/tmp/data.bin")); dataOutputStream dos = new DataOutputStream(os); dos.writeByte(0); dos.close();
    D. OutputStream fos = new FileOutputStream ("/tmp/data.bin"); fos.writeByte(0); fos.close();

  • Question 52:

    Given:

    import java.util.ArrayDeque;

    import java.util.Deque;

    public class Counter {

    public static void main(String[] args) {

    Deque deq = new ArrayDeque(2);

    deq.addFirst("one");

    deq.addFirst("two");

    deq.addFirst("three"); // Line 9

    System.out.print(deq.pollLast());

    System.out.print(deq.pollLast());

    System.out.print(deq.pollLast()); // Line 12

    }

    }

    What is the result?

    A. An exception is thrown at runtime on line 9.
    B. An exception is thrown at runtime on line 12
    C. one two null
    D. one two three
    E. two one null
    F. three two one

  • Question 53:

    Given:

    import java.util.*;

    public class CompareTest {

    public static void main(String[] args) {

    TreeSet set1 = new TreeSet(

    new Comparator() {

    public boolean compare(String s1, String s2) {

    return s1.length() > s2.length();

    }

    });

    set1.add("peach");

    set1.add("orange");

    set1.add("apple");

    for (String n: set1) {

    System.out.println(n);

    }

    }

    }

    What is the result?

    A. peach orange apple
    B. peach orange
    C. apple orange
    D. The program does not compile.
    E. The program generates an exception at runtime.

  • Question 54:

    Given:

    import java.util.*;

    public class SearchText {

    public static void main(String[] args) {

    Object[] array1 = new Object[3];

    array1[0] = "foo";

    array1[0] = 1;

    array1[0] = 'a';

    int index = Arrays.binarySearch(array1, "bar");

    System.out.println(index);

    }

    }

    What is the result?

    A. ?1
    C. 2
    D. Compilation fails
    E. An exception is thrown at runtime

  • Question 55:

    Given:

    public class SuperThread extends Thread {

    public void run(String name) {

    System.out.print("Thread");

    }

    public void run(Runnable r) {

    r = new runnable() {

    public void run() {

    System.out.print("Runnable");

    }

    };

    }

    public static void main(String[] args) {

    Thread t = new SuperThread();

    A. start(); } } Which two are true?
    B. Thread is printed
    C. Runnable is printed
    D. No output is produced
    E. No new threads of execution are started within the main method
    F. One new thread of execution is started within the main method
    G. Two new threads of exclusion are started within the main method

  • Question 56:

    Given the code fragment:

    public void ReadFile (String source) {

    char[] c = new char [128];

    int cLen = c.length;

    try (FileReader fr = new FileReader (source)) {

    int count = 0;

    int read = 0;

    while ((read = fr.read(c)) != -1) {

    count += read;

    }

    System.out.println("Read: " + count + " characters.");

    } catch (IOException i) {

    }

    What change should you make to this code to read and write strings instead of character arrays?

    A. Change FileReader to Readers.
    B. Change FileReader to DataReader.
    C. Change FileReader to File.
    D. Change FileReader to BufferReader.

  • Question 57:

    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 Hoes the matcher in this fragment match? PathMatcher matcher = FileSystems.getDefault ().getPathMatcher ("glob: *???_*1?" );

    A. One
    B. Two
    C. Three
    D. Four
    E. Five
    F. Six

  • Question 58:

    What is the result of invoking Car's scop method?

    A. Both vehicles and Motorized's stop methods are invoked.
    B. Vehicles stop method is invoked.
    C. Motorized's stop method is invoked-
    D. The implementation of the Car's stop determines the behavior.
    E. Compilation fails.

  • Question 59:

    Given the code fragment:

    SimpleDataFormat sdf;

    Which code fragment displays the three-character month abbreviation?

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

  • Question 60:

    Given: public class A { //Line 1 private void a() {}; //Line 2 class B { //Line 3 private void b(){{ //Line 4 a();{ //Line 5 }{ //Line 6 }{ //Line 7 public static void main(String[] args) {{ //Line 8

    A. B b = new A().new B();{ //Line 9
    B. b();{ //Line 10 }{ //Line 11 }{ //Line 12 What is the result?
    C. Compilation fails at line 9
    D. Compilation fails at line 10
    E. Compilation fails at line 5
    F. Compilation fails at line 3
    G. Compilation succeeds

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.