1z0-809 Pre-Exam Practice Tests (Updated 195 Questions) [Q25-Q40]

Share

1z0-809 Pre-Exam Practice Tests | (Updated 195 Questions)

Valid 1z0-809 Exam Q&A PDF - One Year Free Update

NEW QUESTION 25
Given the definition of the Country class:
public class country {
public enum Continent {ASIA, EUROPE}
String name;
Continent region;
public Country (String na, Continent reg) {
name = na, region = reg;
}
public String getName () {return name;}
public Continent getRegion () {return region;}
}
and the code fragment:
List<Country> couList = Arrays.asList (
new Country ("Japan", Country.Continent.ASIA),
new Country ("Italy", Country.Continent.EUROPE),
new Country ("Germany", Country.Continent.EUROPE)); Map<Country.Continent, List<String>> regionNames = couList.stream () .collect(Collectors.groupingBy (Country ::getRegion, Collectors.mapping(Country::getName, Collectors.toList())))); System.out.println(regionNames);
What is the output?

  • A. {EUROPE = [Italy, Germany], ASIA = [Japan]}
  • B. {EUROPE = [Germany, Italy], ASIA = [Japan]}
  • C. {EUROPE = [Germany], EUROPE = [Italy], ASIA = [Japan]}
  • D. {ASIA = [Japan], EUROPE = [Italy, Germany]}

Answer: A

 

NEW QUESTION 26
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. A SQLException is thrown as runtime.
  • B. The program executes successfully and the STUDENT table is updated with one record.
  • C. A NullPointerException is thrown as runtime.
  • D. The program executes successfully and the STUDENT table is NOT updated with any record.

Answer: A

 

NEW QUESTION 27
Given the code fragment:

Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the dbURL, userName, and passWord exists The Employee table has a column ID of type integer and the SQL query matches one record.
What is the result?

  • A. Compilation fails at line 15.
  • B. Compilation fails at line 14.
  • C. The code prints the employee ID.
  • D. The code prints Error.

Answer: B

 

NEW QUESTION 28
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;
}
public String getCourse() {return course;}
public String getName() {return name;}
public String getCity() {return 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(res));
What is the result?

  • A. Java EEJava ME
  • B. [Java ME: Jessy:Chicago, Java ME: Mark:Chicago][Java EE: Helen:Houston]
  • C. [Java EE: Helen:Houston][Java ME: Jessy:Chicago, Java ME: Mark:Chicago]
  • D. A compilation error occurs.

Answer: A

 

NEW QUESTION 29
Given the code fragment:
ZonedDateTime depart = ZonedDateTime.of(2015, 1, 15, 3, 0, 0, 0, ZoneID.of("UTC-
7"));
ZonedDateTime arrive = ZonedDateTime.of(2015, 1, 15, 9, 0, 0, 0, ZoneID.of("UTC-
5"));
long hrs = ChronoUnit.HOURS.between(depart, arrive); //line n1
System.out.println("Travel time is" + hrs + "hours");
What is the result?
Travel time is 4 hours

  • A. An exception is thrown at line n1.
  • B.
  • C. Travel time is 8 hours
  • D. Travel time is 6 hours

Answer: D

 

NEW QUESTION 30
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. .map(Emp::getfName).sorted(Comparator.reserveOrder().map(Emp::getlName).reserved
  • B. .map(Emp::getfName).sorted(Comparator.reserveOrder())
  • C. .sorted (Comparator.comparing(Emp::getfName).reserved().thenComparing(Emp::getlName))
  • D. .sorted (Comparator.comparing(Emp::getfName).thenComparing(Emp::getlName))

Answer: D

 

NEW QUESTION 31
Given:

and the code fragment:

Which modification enables the code fragment to print Speaker?

  • A. Replace line n2 with:
    .filter (p -> Product: :ProductFilter: :isAvailable ())
  • B. Replace line n1 with:
    public static boolean isAvailable (Product p) {
  • C. Replace line n2 with:
    .filter (p -> p.ProductFilter: :isAvailable (p))
  • D. Implement Predicate in the Product.ProductFilter class and replace line n2 with .filter (p
    -> p.ProductFilter.test (p))

Answer: B

 

NEW QUESTION 32
Given the code fragment:

What is the result?

  • A. A B D
  • B. A B C D
  • C. A B C C
  • D. A C D
  • E. A B D C

Answer: C

 

NEW QUESTION 33
Given the code fragment:

Assume that the value of now is 6:30 in the morning.
What is the result?

  • A. 0
  • B. 1
  • C. 2
  • D. An exception is thrown at run time.

Answer: B

 

NEW QUESTION 34
Given:

And given the commands:
javac Test . java
java Test
What is the result?

  • A. A NullPointerException is thrown at runtime.
  • B. Compilation fails at line n1.
  • C. Java EE
  • D. java SE

Answer: A

 

NEW QUESTION 35
Which statement is true about the DriverManager class?

  • A. It returns an instance of Connection.
  • B. It executes SQL statements against the database.
  • C. it is written by different vendors for their specific database.
  • D. It only queries metadata of the database.

Answer: A

Explanation:
Explanation
The DriverManager returns an instance of Doctrine\DBAL\Connection which is a wrapper around the underlying driver connection (which is often a PDO instance).
References:

 

NEW QUESTION 36
Given: What is the result?

  • A. Marrown NanRed JesOran
  • B. Marrown String out of limits
  • C. Marrown String out of limits JesOran
  • D. Marrown String out of limits Array out of limits

Answer: C

 

NEW QUESTION 37
Given the definition of the Vehicle class:
class Vehicle {
String name;
void setName (String name) {
this.name = name;
}
String getName() {
return name;
}
}
Which action encapsulates the Vehicle class?

  • A. Make the name variable public.
  • B. Make the Vehicle class public.
  • C. Make the setName method public.
  • D. Make the setName method private.
  • E. Make the getName method private.
  • F. Make the name variable private.

Answer: A

 

NEW QUESTION 38
Given the code fragment:
public void recDelete (String dirName) throws IOException {
File [ ] listOfFiles = new File (dirName) .listFiles();
if (listOfFiles ! = null && listOfFiles.length >0) {
for (File aFile : listOfFiles) {
if (!aFile.isDirectory ()) {
if (aFile.getName ().endsWith (".class"))
aFile.delete ();
}
}
}
}
Assume that Projects contains subdirectories that contain .class files and is passed as an argument to the recDelete () method when it is invoked.
What is the result?

  • A. The method executes and does not make any changes to the Projects directory.
  • B. The method throws an IOException.
  • C. The method deletes all the .class files in the Projects directory and its subdirectories.
  • D. The method deletes the .class files of the Projects directory only.

Answer: D

 

NEW QUESTION 39
Given the code fragment:

Which two modifications should you make so that the code compiles successfully?

  • A. Replace line 13 with:
  • B. Replace line 5 with public void printFileContent ( ) throws IOException (
  • C. Replace line 11 with public static void main (String [ ] args) throws Exception (
  • D. At line 14, insert throw new IOException ( );
  • E. Replace line 7 with throw IOException ("Exception raised");

Answer: C,E

 

NEW QUESTION 40
......

Java SE 8 Programmer II Free Update Certification Sample Questions: https://www.practicevce.com/Oracle/1z0-809-practice-exam-dumps.html

Trend for Oracle 1z0-809 pdf dumps before actual exam: https://drive.google.com/open?id=1KIFLKTRnKQlIxR9anji4n_-_opDYFFt8