1Z0-809 Dumps Java SE 8 Programmer II: 100% Valid and Newest Version 1Z0-809 Questions & Answers Shared by Certleader
1Z0-809 Dumps Java SE 8 Programmer II: 100% Valid and Newest Version 1Z0-809 Questions & Answers Shared by Certleader
1Z0-809 Dumps Java SE 8 Programmer II: 100% Valid and Newest Version 1Z0-809 Questions & Answers Shared by Certleader
1Z0-809 Dumps
Java SE 8 Programmer II
https://www.certleader.com/1Z0-809-dumps.html
NEW QUESTION 1
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.name.equals(b name))} 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?
Answer: A
NEW QUESTION 2
Given:
class Sum extends RecursiveAction { //line n1 static final int THRESHOLD_SIZE = 3;
int stIndex, lstIndex; int [ ] data;
public Sum (int [ ]data, int start, int end) { this.data = data;
this stIndex = start; this. lstIndex = end;
}
protected void compute ( ) { int sum = 0;
if (lstIndex – stIndex <= THRESHOLD_SIZE) { for (int i = stIndex; i < lstIndex; i++) {
sum += data [i];
}
System.out.println(sum);
} else {
new Sum (data, stIndex + THRESHOLD_SIZE, lstIndex).fork( ); new Sum (data, stIndex,
Math.min (lstIndex, stIndex + THRESHOLD_SIZE)
).compute ();
}
}
}
and the code fragment:
ForkJoinPool fjPool = new ForkJoinPool ( ); int data [ ] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
fjPool.invoke (new Sum (data, 0, data.length));
and given that the sum of all integers from 1 to 10 is 55. Which statement is true?
Answer: A
NEW QUESTION 3
Given the code fragment:
public class FileThread implements Runnable { String fName;
public FileThread(String fName) { this.fName = fName; } public void run () System.out.println(fName);}
public static void main (String[] args) throws IOException, InterruptedException {
ExecutorService executor = Executors.newCachedThreadPool(); Stream<Path> listOfFiles = Files.walk(Paths.get(“Java Projects”)); listOfFiles.forEach(line -> {
executor.execute(new FileThread(line.getFileName().toString ())); //
line n1
});
executor.shutdown(); executor.awaitTermination(5, TimeUnit.DAYS); // line n2
}
}
The Java Projects directory exists and contains a list of files. What is the result?
Answer: B
NEW QUESTION 4
Given the code fragment:
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
NEW QUESTION 5
Given the code fragment:
Stream<Path> files = Files.walk(Paths.get(System.getProperty(“user.home”))); files.forEach (fName -> { //line n1
try {
Path aPath = fName.toAbsolutePath(); //line n2 System.out.println(fName + “:”
+ Files.readAttributes(aPath, Basic.File.Attributes.class).creationTime ());
} catch (IOException ex) { ex.printStackTrace();
});
What is the result?
A. All files and directories under the home directory are listed along with their attributes.
B. A compilation error occurs at line n1.
C. The files in the home directory are listed along with their attributes.
D. A compilation error occurs at line n2.
Answer: A
NEW QUESTION 6
Which statement is true about java.time.Duration?
Answer: C
NEW QUESTION 7
Given:
Answer: C
NEW QUESTION 8
Given the code fragment:
List<String> codes = Arrays.asList (“DOC”, “MPEG”, “JPEG”); codes.forEach (c -> System.out.print(c + “ “));
String fmt = codes.stream()
.filter (s-> s.contains (“PEG”))
Answer: A
NEW QUESTION 9
Given the code fragment:
List<Integer> values = Arrays.asList (1, 2, 3); values.stream ()
.map(n -> n*2) //line n1
.p eek(System.out::print) //line n2
.count();
What is the result?
A. 246
B. The code produces no output.
C. A compilation error occurs at line n1.
D. A compilation error occurs at line n2.
Answer: A
NEW QUESTION 10
Which class definition compiles?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
NEW QUESTION 10
Given the code fragment:
Path p1 = Paths.get(“/Pics/MyPic.jpeg”); System.out.println (p1.getNameCount() + “:” + p1.getName(1) +
“:” + p1.getFileName());
Answer: B
NEW QUESTION 12
Given the code fragment:
Path file = Paths.get (“courses.txt”);
// line n1
Assume the courses.txt is accessible.
Which code fragment can be inserted at line n1 to enable the code to print the content of the courses.txt file?
Answer: D
NEW QUESTION 17
Given:
Answer: C
NEW QUESTION 22
Which two statements are true about synchronization and locks? (Choose two.)
A. A thread automatically acquires the intrinsic lock on a synchronized statement when executed.
B. The intrinsic lock will be retained by a thread if return from a synchronized method is caused by an uncaught exception.
C. A thread exclusively owns the intrinsic lock of an object between the time it acquires the lock and the time itreleases it.
D. A thread automatically acquires the intrinsic lock on a synchronized method’s object when entering that method.
Answer: AB
NEW QUESTION 23
Given:
Answer: A
NEW QUESTION 26
Given:
IntStream stream = IntStream.of (1,2,3); IntFunction<Integer> inFu= x -> y -> x*y; //line n1
IntStream newStream = stream.map(inFu.apply(10)); //line n2 newStream.forEach(System.output::print);
Which modification enables the code fragment to compile?
Answer: B
NEW QUESTION 27
Given the code fragment:
A. Properties prop = new Properties(); prop.put (“user”, userName); prop.put (“password”, password);con = DriverManager.getConnection (dbURL, prop);
B. con = DriverManager.getConnection (userName, password, dbURL);
C. Properties prop = new Properties(); prop.put (“userid”, userName); prop.put (“password”, password); prop.put(“url”, dbURL);con =
DriverManager.getConnection (prop);
D. con = DriverManager.getConnection (dbURL); con.setClientInfo (“user”, userName); con.setClientInfo (“password”, password);
Answer: A
NEW QUESTION 32
Given the structure of the Student table: Student (id INTEGER, name VARCHAR) Given the records from the STUDENT table:
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the dbURL, userName, and passWord exists. What is the result?
A. The program prints Status: true and two records are deleted from the Student table.
B. The program prints Status: false and two records are deleted from the Student table.
C. A SQLException is thrown at runtime.
D. The program prints Status: false but the records from the Student table are not deleted.
Answer: B
NEW QUESTION 34
Given the code fragment: public class Foo {
public static void main (String [ ] args) {
Map<Integer, String> unsortMap = new HashMap< > ( ); unsortMap.put (10, “z”);
unsortMap.put (5, “b”);
unsortMap.put (1, “d”);
unsortMap.put (7, “e”);
unsortMap.put (50, “j”);
Map<Integer, String> treeMap = new TreeMap <Integer, String> (new Comparator<Integer> ( ) {
@Override public int compare (Integer o1, Integer o2) {return o2.compareTo
(o1); } } );
treeMap.putAll (unsortMap);
for (Map.Entry<Integer, String> entry : treeMap.entrySet () ) { System.out.print (entry.getValue () + “ “);
}
}
}
What is the result?
Answer: C
NEW QUESTION 35
A. $15.00
B. 15 $
C. USD 15.00
D. USD $15
Answer: A
NEW QUESTION 39
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)
.f ilter(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: B
NEW QUESTION 43
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: C
NEW QUESTION 47
Given the code fragments:
public class Book implements Comparator<Book> { String name;
double price; public Book () {}
public Book(String name, double price) { this.name = name;
this.price = price;
}
public int compare(Book b1, Book b2) { return b1.name.compareTo(b2.name);
}
public String toString() { return name + “:” + price;
}
}
and
List<Book>books = Arrays.asList (new Book (“Beginning with Java”, 2), new book (“A
Guide to Java Tour”, 3));
Collections.sort(books, new Book()); System.out.print(books);
What is the result?
Answer: A
NEW QUESTION 50
Given:
Which two code fragments, when inserted at line n1 independently, enable the code to print TruckCarBike?
Answer: B
NEW QUESTION 55
Given:
class CheckClass {
public static int checkValue (String s1, String s2) { return s1 length() – s2.length();
}
}
and the code fragment:
String[] strArray = new String [] {“Tiger”, “Rat”, “Cat”, “Lion”}
//line n1
for (String s : strArray) { System.out.print (s + “ “);
}
Which code fragment should be inserted at line n1 to enable the code to print Rat Cat Lion Tiger?
Answer: A
NEW QUESTION 56
Given:
Which two interfaces can you use to create lambda expressions? (Choose two.)
A. T
B. R
C. P
D. S
E. Q
F. U
Answer: AF
NEW QUESTION 61
Given:
and
Which interface from the java.util.function package should you use to refactor the class Txt?
A. Consumer
B. Predicate
C. Supplier
D. Function
Answer: C
NEW QUESTION 64
Given the code fragment:
LocalDate valentinesDay =LocalDate.of(2015, Month.FEBRUARY, 14); LocalDate nextYear = valentinesDay.plusYears(1); nextYear.plusDays(15); //line n1
System.out.println(nextYear); What is the result?
A. 2016-02-14
B. A DateTimeException is throw
C. 2016-02-29
D. A compilation error occurs at line n1.
Answer: A
NEW QUESTION 66
Given the code fragment:
List<Integer> nums = Arrays.asList (10, 20, 8): System.out.println (
//line n1
);
Which code fragment must be inserted at line n1 to enable the code to print the maximum number in the nums list?
Answer: A
NEW QUESTION 71
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 ()
.c ollect(Collectors.groupingBy (Country ::getRegion, Collectors.mapping(Country::getName, Collectors.toList())))); System.out.println(regionNames);
Answer: B
NEW QUESTION 74
Given the code fragment:
Answer: C
NEW QUESTION 75
Given:
class RateOfInterest {
public static void main (String[] args) { int rateOfInterest = 0;
String accountType = “LOAN”; switch (accountType) {
case “RD”; rateOfInterest = 5; break;
case “FD”; rateOfInterest = 10; break;
default:
assert false: “No interest for this account”; //line n1
}
System.out.println (“Rate of interest:” + rateOfInterest);
}
}
and the command:
java –ea RateOfInterest What is the result?
A. Rate of interest: 0
B. An AssertionError is thrown.
C. No interest for this account
D. A compilation error occurs at line n1.
Answer: B
NEW QUESTION 80
The data.doc, data.txt and data.xml files are accessible and contain text. Given the code fragment:
Stream<Path> paths = Stream.of (Paths. get(“data.doc”),
Paths. get(“data.txt”),
Paths. get(“data.xml”));
paths.filter(s-> s.toString().endWith(“txt”)).forEach( s -> {
try { Files.readAllLines(s)
.stream()
.f orEach(System.out::println); //line n1
} catch (IOException e) { System.out.println(“Exception”);
}
}
);
What is the result?
Answer: A
NEW QUESTION 81
Given:
class Vehicle { int vno;
String name;
public Vehicle (int vno, String name) { this.vno = vno,;
this.name = name;
}
public String toString () { return vno + “:” + name;
}
}
and this code fragment:
Set<Vehicle> vehicles = new TreeSet <> (); vehicles.add(new Vehicle (10123, “Ford”)); vehicles.add(new Vehicle (10124, “BMW”)); System.out.println(vehicles);
What is the result?
Answer: D
NEW QUESTION 86
Given the code fragments:
and
Answer: C
NEW QUESTION 90
Given:
Answer: C
NEW QUESTION 92
For which three objects must a vendor provide implementations in its JDBC driver? (Choose three.)
A. Time
B. Date
C. Statement
D. ResultSet
E. Connection
F. SQLException
G. DriverManager
Answer: CDE
Explanation:
Database vendors support JDBC through the JDBC driver interface or through the ODBC connection. Each driver must provide implementations of
java.sql.Connection, java.sql.Statement, java.sql.PreparedStatement, java.sql.CallableStatement, and java.sql.Re sultSet. They must also implement the
java.sql.Driver interface for use by the generic java.sql.DriverManager interface.
NEW QUESTION 94
Given:
final class Folder { //line n1
//line n2
public void open () { System.out.print(“Open”);
}
}
public class Test {
public static void main (String [] args) throws Exception { try (Folder f = new Folder()) {
A. f.open();}}}Which two modifications enable the code to print Open Close? (Choose two.)
B. Replace line n1 with:class Folder implements AutoCloseable {
C. Replace line n1 with:class Folder extends Closeable {
D. Replace line n1 with:class Folder extends Exception {
E. At line n2, insert: final void close () {System.out.print(“Close”);}
F. At line n2, insert:public void close () throws IOException { System.out.print(“Close”);}
Answer: AE
NEW QUESTION 95
Given the code fragment: UnaryOperator<Integer> uo1 = s -> s*2; line n1
List<Double> loanValues = Arrays.asList(1000.0, 2000.0); loanValues.stream()
.filter(lv -> lv >= 1500)
.map(lv -> uo1.apply(lv))
.forEach(s -> System.out.print(s + “ “)); What is the result?
A. 4000.0
B. 4000
C. A compilation error occurs at line n1.
D. A compilation error occurs at line n2.
Answer: D
Answer: C
Answer: B
Answer: A
public default void walk (Integer distance) {System.out.println(“Walking”);) public void run(Integer distance);
}
Which statement is true?
Answer: A
Answer: A
A. The program prints: Run RunnerCall Caller : nullAnd the program does not terminate.
B. The program terminates after printing: Run RunnerCall Caller : Run
Answer: A
Assume that the value of now is 6:30 in the morning. What is the result?
Answer: D
Answer: B
A. You expect that classes that implement your interfaces have many common methods or fields, or require access modifiers other than public.
B. You expect that unrelated classes would implement your interfaces.
C. You want to share code among several closely related classes.
D. You want to declare non-static on non-final fields.
E. You want to take advantage of multiple inheritance of type.
Answer: BE
and
Which two modifications enable to sort the elements of the emps list? (Choose two.)
Answer: CE
A. 0 : 0 : pen
B. 0 : 1 : pen
C. 0 : 0 : 0 : 0 : 0 : pen
D. 0 : 1 : 2 : 3 : 4 :
E. A compilation error occurs.
Answer: A
Answer: A
Answer: C
A. truetrue
B. falsetrue
C. falsefalse
D. truefalse
Answer: B
A. New York
B. City Not available
C. null
D. A NoSuchElementException is thrown at run time.
Answer: B
A. Add the driver class to the META-INF/services folder of the JAR file.
B. Include the JDBC driver class in a jdbc.properties file.
C. Use the java.lang.Class.forName method to load the driver class.
D. Use the DriverManager.getDriver method to load the driver class.
Answer: C
Answer: B
Answer: B
100% Pass Your 1Z0-809 Exam with Our Prep Materials Via below:
https://www.certleader.com/1Z0-809-dumps.html