Exam Details

  • Exam Code
    :1Z0-809
  • Exam Name
    :Java SE 8 Programmer II
  • Certification
    :Oracle Database
  • Vendor
    :Oracle
  • Total Questions
    :207 Q&As
  • Last Updated
    :May 05, 2024

Oracle Oracle Database 1Z0-809 Questions & Answers

  • Question 21:

    Given:

    class UserException extends Exception { }

    class AgeOutOfLimitException extends UserException { }

    and the code fragment:

    class App {

    public void doRegister(String name, int age)

    throws UserException, AgeOutOfLimitException {

    if (name.length () <= 60) {

    throw new UserException ();

    } else if (age > 60) {

    throw new AgeOutOfLimitException ();

    } else {

    System.out.println("User is registered.");

    }

    }

    public static void main(String[ ] args) throws UserException {

    App t = new App ();

    A. doRegister("Mathew", 60); } } What is the result?

    B. User is registered.

    C. An AgeOutOfLimitException is thrown.

    D. A UserException is thrown.

    E. A compilation error occurs in the main method.

  • Question 22:

    Given the code fragment:

    public class Foo {

    public static void main (String [ ] args) {

    Map unsortMap = new HashMap< > ( );

    unsortMap.put (10, "z");

    unsortMap.put (5, "b");

    unsortMap.put (1, "d");

    unsortMap.put (7, "e");

    unsortMap.put (50, "j");

    Map treeMap = new TreeMap (new

    Comparator ( ) {

    @Override public int compare (Integer o1, Integer o2) {return o2.compareTo (o2); } } );

    treeMap.putAll (unsortMap);

    for (Map.Entry entry : treeMap.entrySet () ) {

    System.out.print (entry.getValue () + " ");

    }

    }

    }

    What is the result?

    A. A compilation error occurs.

    B. d b e z j

    C. j z e b d

    D. z b d e j

  • Question 23:

    Given the code fragments:

    class Caller implements Callable {

    String str;

    public Caller (String s) {this.str=s;}

    public String call()throws Exception { return str.concat ("Caller");}

    }

    class Runner implements Runnable {

    String str;

    public Runner (String s) {this.str=s;}

    public void run () { System.out.println (str.concat ("Runner"));}

    }

    and

    public static void main (String[] args) throws InterruptedException, ExecutionException { ExecutorService

    es = Executors.newFixedThreadPool(2);

    Future f1 = es.submit (new Caller ("Call"));

    Future f2 = es.submit (new Runner ("Run"));

    String str1 = (String) f1.get();

    String str2 = (String) f2.get(); //line n1

    System.out.println(str1+ ":" + str2);

    }

    What is the result?

    A. The program prints:

    Run Runner

    Call Caller : null

    And the program does not terminate.

    B. The program terminates after printing: Run Runner Call Caller : Run

    C. A compilation error occurs at line n1.

    D. An Execution is thrown at run time.

  • Question 24:

    Given:

    class Vehicle implements Comparable{

    int vno;

    String name;

    public Vehicle (int vno, String name) {

    this.vno = vno,;

    this.name = name;

    }

    public String toString () {

    return vno + ":" + name;

    }

    public int compareTo(Vehicle o) {

    return this.name.compareTo(o.name);

    }

    and this code fragment:

    Set vehicles = new TreeSet <> ();

    vehicles.add(new Vehicle (10123, "Ford"));

    vehicles.add(new Vehicle (10124, "BMW"));

    System.out.println(vehicles);

    What is the result?

    A. [10123:Ford, 10124:BMW]

    B. [10124:BMW, 10123:Ford]

    C. A compilation error occurs.

    D. A ClassCastException is thrown at run time.

  • Question 25:

    Given that course.txt is accessible and contains:

    Course : : Java

    and given the code fragment:

    public static void main (String[ ] args) {

    int i;

    char c;

    try (FileInputStream fis = new FileInputStream ("course.txt");

    InputStreamReader isr = new InputStreamReader(fis);) {

    while (!isr.close()) { //line n1

    isr.skip(2);

    i = isr.read ();

    c = (char) i;

    System.out.print(c);

    }

    } catch (Exception e) {

    A. printStackTrace(); } } What is the result?

    B. ur :: va

    C. ueJa

    D. The program prints nothing.

    E. A compilation error occurs at line n1.

  • Question 26:

    Given the code fragment:

    List colors = Arrays.asList("red", "green", "yellow");

    Predicate test = n - > {

    System.out.println("Searching...");

    return n.contains("red");

    };

    colors.stream()

    .filter(c -> c.length() >= 3)

    .allMatch(test);

    What is the result?

    A. Searching...

    B. Searching... Searching...

    C. Searching... Searching... Searching...

    D. A compilation error occurs.

  • Question 27:

    Given the definition of the Emp class:

    public class Emp

    private String eName;

    private Integer eAge;

    Emp(String eN, Integer eA) {

    this.eName = eN;

    this.eAge = eA;

    }

    public Integer getEAge () {return eAge;}

    public String getEName () {return eName;}

    }

    and code fragment:

    Listli = Arrays.asList(new Emp("Sam", 20), New Emp("John", 60), New Emp("Jim", 51));

    Predicate agVal = s -> s.getEAge() <= 60; //line n1

    li = li.stream().filter(agVal).collect(Collectors.toList());

    Stream names = li.stream()map.(Emp::getEName); //line n2

    names.forEach(n -> System.out.print(n + " "));

    What is the result?

    A. Sam John Jim

    B. John Jim

    C. A compilation error occurs at line n1.

    D. A compilation error occurs at line n2.

  • Question 28:

    Given:

    class Book {

    int id;

    String name;

    public Book (int id, String name) {

    this.id = id;

    this.name = name;

    }

    public boolean equals (Object obj) { //line n1

    boolean output = false;

    Book b = (Book) obj;

    if (this.id = = b.id) {

    output = true;

    }

    return output;

    }

    }

    and the code fragment:

    Book b1 = new Book (101, "Java Programing");

    Book b2 = new Book (102, "Java Programing");

    System.out.println (b1.equals(b2)); //line n2

    Which statement is true?

    A. The program prints true.

    B. The program prints false.

    C. A compilation error occurs. To ensure successful compilation, replace line n1 with: boolean equals (Book obj) {

    D. A compilation error occurs. To ensure successful compilation, replace line n2 with: System.out.println (b1.equals((Object) b2));

  • Question 29:

    Given the code fragment:

    Path path1 = Paths.get("/app/./sys/");

    Path res1 = path1.resolve("log");

    Path path2 = Paths.get("/server/exe/");

    Path res1 = path2.resolve("/readme/");

    System.out.println(res1);

    System.out.println(res2);

    What is the result?

    A. /app/sys/log /readme/server/exe

    B. /app/log/sys /server/exe/readme

    C. /app/./sys/log /readme

    D. /app/./sys/log /server/exe/readme

  • Question 30:

    Given the code fragment:

    List nL = Arrays.asList("Jim", "John", "Jeff");

    Function funVal = s -> "Hello : ".concat(s);

    nL.Stream()

    .map(funVal)

    .forEach(s-> System.out.print (s));

    What is the result?

    A. Hello : Jim Hello : John Hello : Jeff

    B. Jim John Jeff

    C. The program prints nothing.

    D. A compilation error occurs.

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