1Z0-805 Exam Details

  • Exam Code
    :1Z0-805
  • Exam Name
    :Upgrade to Java SE 7 Programmer
  • Certification
    :Oracle Certifications
  • Vendor
    :Oracle
  • Total Questions
    :90 Q&As
  • Last Updated
    :Dec 09, 2021

Oracle 1Z0-805 Online Questions & Answers

  • Question 21:

    Given the code fragment:

    public static void main(String[] args) {

    Path file = Paths.get("D:\\company\\report.txt");

    try (SeekableByteChannel sbc = Files.newByteChannel(file,new OpenOption[]

    What is the result if the report.txt file contains

    Welcome to the world of Java?

    A. The file contains the first five characters.
    B. The file contains the first four characters.
    C. The contents of the file remain unchanged.
    D. A NonWritableChannelException is thrown at runtime.

  • Question 22:

    Given:

    class Fibonacci extends RecursiveTask {

    final int n;

    Fibonacci (int n) { this.n = n }

    Integer compute () {

    if (n <= 1)

    return n;

    Fibonacci f1 = new Fibonacci (n ?1);

    f1.fork; // Line X

    Fibonacci f2 = new Fibonacci (n ?2); // Line Y

    return f2.compute() + f1.join;

    }

    }

    Suppose that lines X and Y are transposed:

    Fibonacci f2 = new Fibonacci (n ?2); // Line Y

    f1.fork; // Line X

    What is the likely result?

    A. The program produces the correct result, with similar performance to the original
    B. The program produces the correct result, with performance degraded to the equivalent of being single-threaded.
    C. The program produces an incorrect result
    D. The program goes into an infinite loop
    E. An exception is thrown at runtime
    F. The program produces the correct result, the better performance than the original.

  • Question 23:

    Given the following code fragment:

    public static void getInfo() {

    //insert code here

    List fontCatalog = new ArrayList();

    fontCatalog.add("Algerian");

    fontCatalog.add("Cambria");

    fontCatalog.add("Lucida Bright");

    category.put("firstCategory",fontCatalog);

    List entrySet = new ArrayList(category.entrySet());

    Iterator it = entrySet.iterator();

    while(it.hasNext())

    { System.out.println(it.next)

    );

    }

    }

    Which two code fragments, when inserted independently at line **, enable the code to compile?

    A. Map category = new HashMap ();
    B. Map category = new HashMap();
    C. Map category = new HashMap ();
    D. Map category = new HashMap ();
    E. Map category = new HashMap ();
    F. Map category = new HashMap ();

  • Question 24:

    Given three resource bundles with these values set for menu1: ( The default resource bundle is English US resource Bundle Menu1 = small French resource Bundle Menu1 = petit Chinese Resource Bundle Menu = 1 And given the code fragment: Locale.setDefault (new Locale("es", "ES")); // Set default to Spanish and Spain loc1 = Locale.getDefault(); ResourceBundle messages = ResourceBundle.getBundle ("messageBundle", loc1); System.out.println (messages.getString("menu1")); What is the result?

    A. No message is printed
    B. petit
    C. :
    D. Small
    E. A runtime error is produced

  • Question 25:

    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)); 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 26:

    Given the error message when running you application:

    Exception in thread "main" java.util.MissingResourceException: can't find bundle for base name messageBundle, Locale

    And given that the Message Bundle.properties file has been created, exists on your disk, and is properly formatted.

    What is the cause of the error message?

    A. The file is not in the environment PATH.
    B. The file is not in the CLASSPATH.
    C. The file is not in the JJAVAPATH.
    D. You cannot use a file to store a ResourceBundle.

  • Question 27:

    What are two benefits of a Factory design pattern?

    A. Eliminates direct constructor calls in favor of invoking a method
    B. Provides a mechanism to monitor objects for changes
    C. Eliminates the need to overload constructors in a class implementation
    D. Prevents the compile from complaining about abstract method signatures
    E. Prevents tight coupling between your application and a class implementation

  • Question 28:

    Given the code fragment: public class TestString { public static void main(String[] args)

    { String str=null;

    switch(str) { case "":

    System.out.println("blank"); break;

    case "null":

    System.out.println("NULL"); break;

    default: System.out.println("invalid");

    break;

    }

    }

    }

    What is the result?

    A. Compilation fails
    B. Blank
    C. NULL
    D. An exception is thrown at runtime
    E. Invalid

  • Question 29:

    Which is a key aspect of composition?

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

  • Question 30:

    Given:

    public class MyGrades {

    private final List myGrades = new ArrayList();

    private final ReadWriteLock rwlock = new ReentrantReadWriteLock();

    public void addGrade(Integer grade) {

    // acquire lock

    myGrades.add(grade);

    // release lock

    }

    public void averageGrades() {

    // acquire lock Line **

    double sum = 0;

    int i = 0;

    for (i = 0; i < myGrades.size(); i++) {

    sum += myGrades.get(i);

    }

    // release lock Line ***

    System.out.println("The average is: " + sum/(i+1));

    }

    }

    Which pair's statements should you insert at lines ** and lines *** (respectively) to acquire and release the most appropriate lock?

    A. rwlock.readLock().acquire(); rwlock.readLock().release();
    B. rwlock.readLock().lock(); rwlock.readLock().unlock();
    C. rwlock.getLock().acquire(); rwlock.getLock().release();
    D. rwlock.getLock().lock(); rwlock.getLock().Unlock();
    E. relock.WriteLock().acquire(); rwlock.writeLock().release();
    F. rwlock.writeLock().lock(); rwlock.WriteLock().unlock();

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-805 exam preparations and Oracle certification application, do not hesitate to visit our Vcedump.com to find your solutions here.