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 definition of the Vehicle class: 

Class Vehhicle { 

int distance;//line n1 

Vehicle (int x) { 

this distance = x; 

public void increSpeed(int time) {//line n2 

int timeTravel = time;//line n3 

class Car { 

int value = 0; 

public void speed () { 

value = distance /timeTravel; 

System.out.println (“Velocity with new speed”+value+”kmph”); 

new Car().speed(); 

and this code fragment: 

Vehicle v = new Vehicle (100); 

v.increSpeed(60); 

What is the result? 

A. Velocity with new speed 

B. A compilation error occurs at line n1. 

C. A compilation error occurs at line n2. 

D. A compilation error occurs at line n3. 

Answer:

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

A. Arrays.sort(strArray, CheckClass : : checkValue); 

B. Arrays.sort(strArray, (CheckClass : : new) : : checkValue); 

C. Arrays.sort(strArray, (CheckClass : : new).checkValue); 

D. Arrays.sort(strArray, CheckClass : : new : : checkValue); 

Answer:

Q3. Given: 

class Bird { 

public void fly () { System.out.print(“Can fly”); } 

class Penguin extends Bird { 

public void fly () { System.out.print(“Cannot fly”); } 

and the code fragment: 

class Birdie { 

public static void main (String [ ] args) { 

fly( ( ) -> new Bird ( )); 

fly (Penguin : : new); 

/* line n1 */ 

Which code fragment, when inserted at line n1, enables the Birdie class to compile? 

A. static void fly (Consumer<Bird> bird) { 

bird :: fly (); } 

B. static void fly (Consumer<? extends Bird> bird) { 

bird.accept( ) fly (); 

C. static void fly (Supplier<Bird> bird) { 

bird.get( ) fly (); 

D. static void fly (Supplier<? extends Bird> bird) { 

LOST 

Answer:

Explanation: NOTE: Very confusing question. There is no logic in the options. 

Q4. Given: 

What is the result? 

A. Null 

B. Compilation fails 

C. An exception is thrown at runtime 

D. 0 

Answer:

Q5. Given the code fragment: 

List<String> nL = Arrays.asList(“Jim”, “John”, “Jeff”); 

Function<String, String> funVal = s -> “Hello : “.contact(s); 

nL.Stream() 

.map(funVal) 

.peek(System.out::print); 

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. 

Answer:

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

Q7. Given: 

What is the result? 

A. 10 : 22 : 20 

B. 10 : 22 : 22 

C. 10 : 22 : 6 

D. 10 : 30 : 6 

Answer:

Q8. Given: 

interface Rideable {Car getCar (String name); } 

class Car { 

private String name; 

public Car (String name) { 

this.name = name; 

Which code fragment creates an instance of Car? 

A. Car auto = Car (“MyCar”): : new; 

B. Car auto = Car : : new; 

Car vehicle = auto : : getCar(“MyCar”); 

C. Rideable rider = Car : : new; 

Car vehicle = rider.getCar(“MyCar”); 

D. Car vehicle = Rideable : : new : : getCar(“MyCar”); 

Answer:

Q9. Which two statements are true for a two-dimensional array? 

A. It is implemented as an array of the specified element type. 

B. Using a row by column convention, each row of a two-dimensional array must be of the same size. 

C. At 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: A,D 

Q10. Given the code fragment: 

List<String> listVal = Arrays.asList(“Joe”, “Paul”, “Alice”, “Tom”); 

System.out.println ( 

// line n1 

); 

Which code fragment, when inserted at line n1, enables the code to print the count of string elements whose length is greater than three? 

A. listVal.stream().filter(x -> x.length()>3).count() 

B. listVal.stream().map(x -> x.length()>3).count() 

C. listVal.stream().peek(x -> x.length()>3).count().get() 

D. listVal.stream().filter(x -> x.length()>3).mapToInt(x -> x).count() 

Answer: