1z0-809 Oracle Real Exam Questions

1z0-809 Exam Questions Answers

New Updated 1z0-809 Exam Questions from valid4sure 1z0-809 PDF dumps! Welcome to download the newest valid4sure 1z0-809 VCE dumps: (128 Q&As)

  •  Java SE 8 Programmer II certification exam

Keywords: 1z0-809 exam dumps, 1z0-809 exam questions, 1z0-809 VCE dumps, 1z0-809 PDF dumps, 1z0-809 practice tests, 1z0-809 study guide, 1z0-809 braindumps,

PS. New 1z0-809 dumps PDF – https://www.valid4sure.com/top/demo/Oracle/1z0-809.pdf

1z0-809 Practice Test Questions Answers – 1z0-809 braindump



QUESTION NO: 21

Given the code fragments:

 

class MyThread implements Runnable {

     private static AtomicInteger count = new AtomicInteger (0);

     public void run ()   {

          int x = count.incrementAndGet();

          System.out.print (x+” “);

     }

}

 

and

 

Thread thread1 = new Thread(new MyThread());

Thread thread2 = new Thread(new MyThread());

Thread thread3 = new Thread(new MyThread());

 

Thread [] ta = {thread1, thread2, thread3};

for (int x= 0; x < 3; x++)   {

     ta[x].start();

}

 

Which statement is true?

 

A. The program prints 1 2 3 and the order is unpredictable.

B. The program prints 1 2 3.

C. The program prints 1 1 1.

D. A compilation error occurs.

 

Answer: B

 

QUESTION NO: 22

Given the code fragment:

 

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

      BufferedReader br = new BufferedReader (new InputStremReader (System.in));

      System.out.print (“Enter GDP: “);

      //line 1

}

 

Which code fragment, when inserted at line 1, enables the code to read the GDP from the user?

 

A. int GDP = Integer.parseInt (br.readline());

B. int GDP = br.read();

C. int GDP = br.nextInt();

D. int GDP = Integer.parseInt (br.next());

 

Answer: C

 

QUESTION NO: 23

Given the code fragment:

 

Path source = Paths.get (“/data/december/log.txt”);

Path destination = Paths.get(“/data”);

Files.copy (source, destination);

 

and assuming that the file /data/december/log.txt is accessible and contains:

 

10-Dec-2014 – Executed successfully

 

What is the result?

 

A. A file with the name log.txt is created in the /data directory and the content of the /data/december/log.txt file is copied to it.

B. The program executes successfully and does NOT change the file system.

C. A FileNotFoundException is thrown at run time.

D. A FileAlreadyExistsException is thrown at run time.

 

Answer: B

 

QUESTION NO: 24

Given:

 

class Student    {

     String course, name, city;

     public Student (String name, String course, String city)   {

          this.course = course; this.name = name; this.city = city;

     }

     public String toString()    {

          return course + “:” + name + “:” + city;

     }

 

and the code fragment:

 

List<Student> stds = Arrays.asList(

     new Student (“Jessy”, “Java ME”, “Chicago”),

     new Student (“Helen”, “Java EE”, “Houston”),

     new Student (“Mark”, “Java ME”, “Chicago”));

stds.stream()

     .collect(Collectors.groupingBy(Student::getCourse))

     .forEach(src, res) -> System.out.println(scr));

 

What is the result?

 

A. [Java EE: Helen:Houston]

  [Java ME: Jessy:Chicago, Java ME: Mark:Chicago]

B. Java EE

  Java ME

C. [Java ME: Jessy:Chicago, Java ME: Mark:Chicago]

  [Java EE: Helen:Houston]

D. A compilation error occurs.

 

Answer: C

 

QUESTION NO: 25

Given the code fragments:

 

interface CourseFilter extends Predicate<String>    {

     public default boolean test (String str)     {

          return str.equals (“Java”);

     }

}

 

and

 

List<String> strs = Arrays.asList(“Java”, “Java EE”, “Java ME”);

Predicate<String> cf1 = s - > s.length() > 3;

Predicate cf2 = new CourseFilter()   {          //line n1

     public boolean test (String s)  {

          return s.contains (“Java”);

     }

};

long c = strs.stream()

     .filter(cf1)

     .filter(cf2                           //line n2

.count();

System.out.println(c);

 

What is the result?

 

A. 2

B. 3

C. A compilation error occurs at line n1.

D. A compilation error occurs at line n2.

 

Answer: A

 

QUESTION NO: 26

Given:

 

public class Emp   {

     String fName;

     String lName;

     public Emp (String fn, String ln)  {

          fName = fn;

          lName = ln;

     }

     public String getfName() { return fName; }

     public String getlName() { return lName; }

}

 

and the code fragment:

 

List<Emp> emp = Arrays.asList (

     new Emp (“John”, “Smith”),

     new Emp (“Peter”, “Sam”),

     new Emp (“Thomas”, “Wale”));

emp.stream()

     //line n1

     .collect(Collectors.toList());

 

Which code fragment, when inserted at line n1, sorts the employees list in descending order of fName and then ascending order of lName?

 

A. .sorted (Comparator.comparing(Emp::getfName).reserved().thenComparing(Emp::getlName))

B. .sorted (Comparator.comparing(Emp::getfName).thenComparing(Emp::getlName))

C. .map(Emp::getfName).sorted(Comparator.reserveOrder())

D. .map(Emp::getfName).sorted(Comparator.reserveOrder().map(Emp::getlName).reserved

 

Answer: A

 

QUESTION NO: 27

Given:

 

public enum USCurrency   {

     PENNY (1),

     NICKLE(5),

     DIME (10),

     QUARTER(25);

 

     private int value;

 

     public USCurrency(int value)   {

          this.value = value;

     }

     public int getValue()    {return value;}

}

public class Coin {

     public static void main (String[] args)   {

          USCurrency usCoin =new USCurrency.DIME;

          System.out.println(usCoin.getValue()):

     }

}

 

Which two modifications enable the given code to compile?

 

A. Nest the USCurrency enumeration declaration within the Coin class.

B. Make the USCurrency enumeration constructor private.

C. Remove the new keyword from the instantion of usCoin.

D. Make the getter method of value as a static method.

E. Add the final keyword in the declaration of value.

 

Answer:  A, E

 

QUESTION NO: 28

Given:

 

class ImageScanner implements AutoCloseable {

     public void close () throws Exception {

          System.out.print (“Scanner closed.”);

     }

     public void scanImage () throws Exception {

          System.out.print (“Scan.”);

          throw new Exception(“Unable to scan.”);

     }

}

class ImagePrinter implements AutoCloseable {

     public void close () throws Exception {

          System.out.print (“Printer closed.”);

     }

     public void printImage ()  {System.out.print(“Print.”);    }

}

 

and this code fragment:

 

try (ImageScanner ir = new ImageScanner();

          ImagePrinter iw = new ImagePrinter())   {

     ir.scanImage();

     iw.printImage();

}  catch (Exception e)  {

     System.out.print(e.getMessage());

}

 

What is the result?

 

A. Scan.Printer closed. Scanner closed. Unable to scan.

B. Scan.Scanner closed. Unable to scan.

C. Scan. Unable to scan.

D. Scan. Unable to scan. Printer closed.

 

Answer: B

 

QUESTION NO: 29

Given the structure of the STUDENT table:

 

Student (id INTEGER, name VARCHAR)

 

Given:

 

public class Test   {

     static Connection newConnection =null;

     public static Connection get DBConnection () throws SQLException {

          try (Connection con = DriveManager.getConnection(URL, username, password))   {

              newConnection = con;

          }

          return newConnection;

     }

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

          get DBConnection ();

          Statement st = newConnection.createStatement();

          st.executeUpdate(“INSERT INTO student VALUES (102, ‘Kelvin’)”);

     }

}

 

Assume that:

            The required database driver is configured in the classpath.

            The appropriate database is accessible with the URL, userName, and passWord exists.

            The SQL query is valid.

 

What is the result?

 

A. The program executes successfully and the STUDENT table is updated with one record.

B. The program executes successfully and the STUDENT table is NOT updated with any record.

C. A SQLException is thrown as runtime.

D. A NullPointerException is thrown as runtime.

 

Answer: D

 

QUESTION NO: 30

Given the code fragments:

 

class Employee  {

      Optional<Address> address;

      Employee (Optional<Address> address)   {

            this.address = address;

      }

public  Optional<Address> getAddress()   {   return address;   }

}

 

class Address   {

      String city = “New York”;

      public String getCity  {   return city:   }

      public String toString()    {

            return city;

      }

}

 

and

 

Address address = null;

Optional<Address> addrs1 = Optional.ofNullable (address);

Employee e1 = new Employee (addrs1);

String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : “City Not

available”;

 

What is the result?

 

A. New York

B. City Not available

C. null

D. A NoSuchElementException is thrown at run time.

 

Answer: C

This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free