aiotestking uk

1Z0-809 Exam Questions - Online Test


1Z0-809 Premium VCE File

Learn More 100% Pass Guarantee - Dumps Verified - Instant Download
150 Lectures, 20 Hours

Q1. 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:

Q2. 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: 

List<Emp>li = Arrays.asList(new Emp(“Sam”, 20), New Emp(“John”, 60), New Emp(“Jim”, 

51)); 

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

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

Stream<String> 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. 

Answer:

Q3. Given the code fragment: 

List<Integer> list1 = Arrays.asList(10, 20); 

List<Integer> list2 = Arrays.asList(15, 30); 

//line n1 

Which code fragment, when inserted at line n1, prints 10 20 15 30? 

A. Stream.of(list1, list2) 

.flatMap(list -> list.stream()) 

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

B. Stream.of(list1, list2) 

.flatMap(list -> list.intStream()) 

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

C. list1.stream() 

.flatMap(list2.stream().flatMap(e1 -> e1.stream()) 

.forEach(s -> System.out.println(s + “ “)); 

D. Stream.of(list1, list2) 

.flatMapToInt(list -> list.stream()) 

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

Answer:

Q4. Which action can be used to load a database driver by using JDBC3.0? 

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:

Q5. Given: 

interface Doable { 

public void doSomething (String s); 

Which two class definitions compile? 

A. public abstract class Task implements Doable { 

public void doSomethingElse(String s) { } 

B. public abstract class Work implements Doable { 

public abstract void doSomething(String s) { } 

public void doYourThing(Boolean b) { } 

C. public class Job implements Doable { 

public void doSomething(Integer i) { } 

D. public class Action implements Doable { 

public void doSomething(Integer i) { } 

public String doThis(Integer j) { } 

E. public class Do implements Doable { 

public void doSomething(Integer i) { } 

public void doSomething(String s) { } 

public void doThat (String s) { } 

Answer: C,D 

Q6. Given: What is the result? 

A. box 

B. nbo 

C. bo 

D. nb 

E. An exception is thrown at runtime 

Answer:

Q7. 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. {ASIA = [Japan], EUROPE = [Italy, Germany]} 

C. {EUROPE = [Germany, Italy], ASIA = [Japan]} 

D. {EUROPE = [Germany], EUROPE = [Italy], ASIA = [Japan]} 

Answer:

Q8. Given the code fragment: 

What is the result? 

A. Found Red Found Default 

B. Found Teal 

C. Found Red Found Blue Found Teal 

D. Found Red Found Blue Found Teal Found Default 

E. Found Default 

Answer:

Q9. Which two statements are true for a two-dimensional array of primitive data type? 

A. It cannot contain elements of different types. 

B. The length of each dimension must be the same. 

C. At the declaration time, the number of elements of the array in each dimension must be specified. 

D. All methods of the class object may be invoked on the two-dimensional array. 

Answer: C,D 

Explanation: http://stackoverflow.com/questions/12806739/is-an-array-a-primitive-type-or-an-object-or-something-else-entirely 

Q10. 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: