Ensurepass
2017 July Oracle Official New Released 1Z0-809 Q&As
100% Free Download! 100% Pass Guaranteed!
http://www.ensurepass.com/1Z0-809.html

Java SE 8 Programmer II

QUESTION 11

Given:

 

public class product {

 

int id; int price;

 

public Product (int id, int price) {

 

this.id = id;

 

this.price = price;

 

}

 

public String toString() { return id + “:” + price; }

 

}

 

and the code fragment:

 

List<Product> products = Arrays.asList(new Product(1, 10),

 

new Product (2, 30),

 

new Product (2, 30));

 

Product p = products.stream().reduce(new Product (4, 0), (p1, p2) -> {

 

p1.price+=p2.price;

 

return new Product (p1.id, p1.price);});

 

products.add(p);

 

products.stream().parallel()

 

.reduce((p1, p2) – > p1.price > p2.price ? p1 : p2)

 

.ifPresent(System.out: :println);

 

What is the result?

 

A.

2 : 30

B.

4 : 0

C.

4 : 60

D.

4 : 60

2 : 30

3 : 20

1 : 10

E.

The program prints nothing.

 

Correct Answer: D

 

 

QUESTION 12

Given the code fragment:

 

List<Integer
> values = Arrays.asList (1, 2, 3);

 

values.stream ()

 

.map(n -> n*2)//line n1

 

.peek(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.

 

Correct Answer: A

 

 

QUESTION 13

Given the code fragments:

 

clip_image002

 

What is the result?

 

A.

Super

Sub

Sub

B.

Contract

Contract

Super

C.

Compilation fails at line n1

D.

Compilation fails at line n2

 

Correct Answer: D

 

 

QUESTION 14

Given the content of /resourses/Message.properties:

 

welcome1=”Good day!”

 

and given the code fragment:

 

Properties prop = new Properties ();

 

FileInputStream fis = new FileInputStream (“/resources/Message.properties”);

 

prop.load(fis);

 

System.out.println(prop.getProperty(“welcome1”));

 

System.out.println(prop.getProperty(“welcome2”, “Test”));//line n1

 

System.out.println(prop.getProperty(“welcome3”));

 

What is the result?

 

A.

Good day!

Test

followed by an Exception stack trace

B.

Good day!

followed by an Exception stack trace

C.

Good day!

Test

null

D.

A compilation error occurs at line n1.

 

Correct Answer: D

 

 

QUESTION 15

Given:

 

Class A { }

 

Class B { }

 

Interface X { }

 

Interface Y { }

 

Which two definitions of class C are valid?

 

A.

Class C extends A implements X { }

B.

Class C implements Y extends B { }

C.

Class C extends A, B { }

D.

Class C implements X, Y extends B { }

E.

Class C extends B implements X, Y { }

 

Correct Answer: AE

Explanation:

extends is for extending a class.

implements is for implementing an interface.

Java allows for a class to implement many interfaces.

 

 

QUESTION 16

Which statement is true about java.util.stream.Stream?

 

A.

A stream cannot be consumed more than once.

B.

The execution mode of streams can be changed during processing.

C.

Streams are intended to modify the source data.

D.

A parallel stream is always faster than an equivalent sequential stream.

 

Correct Answer: B

 

 

QUESTION 17

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”);

 

Correct Answer: C

 

 

QUESTION 18

Given the code fragments:

 

class Caller implements Callable<String> {

 

String str;

 

public Caller (String s) {this.str=s;}

 

public String call()throws Exception { return str.concat (“Caller”);}

 

}

 

class Runner implements Runnable {

 

String str;

 

public Runner (String s) {this.str=s;}

 

public void run () { System.out.println (str.concat (“Runner”));}

 

}

 

and

 

public static void main (String[] args) InterruptedException, ExecutionException {

 

ExecutorService es = Executors.newFixedThreadPool(2);

 

Future f1 = es.submit (new Caller (“Call”));

 

Future f2 = es.submit (new Runner (“Run”));

 

String str1 = (String) f1.get();

 

String str2 = (String) f2.get();//line n1

 

System.out.println(str1+ “:” + str2);

 

}

 

What is the result?

 

A.

The program prints:

Run Runner

Call Caller : null

And the program does not terminate.

B.

The program terminates after printing:

Run Runner

Call Caller : Run

C.

A compilation error occurs at line n1.

D.

An Execution is thrown at run time.

 

Correct Answer: A

 

 

QUESTION 19

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?

 

A.

The program prints true.

B.

The program prints false.

C.

A compilation error occurs. To ensure successful compilation, replace line n1 with:

boolean equals (Book obj) {

D.

A compilation error occurs. To ensure successful compilation, replace line n2 with:

System.out.println (b1.equals((Object) b2));

 

Correct Answer: C

 

 

QUESTION 20

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.

 

Correct Answer: A

100% Free Download!
—Download Free Demo:1Z0-809 Demo PDF
100% Pass Guaranteed!
Download 2017 Ensurepass 1Z0-809 Full Exam PDF and VCE Q&As:128
—Get 10% off your purchase! Copy it:TJDN-947R-9CCD [2017.07.01-2017.07.31]

Ensurepass ExamCollection Testking
Lowest Price Guarantee Yes No No
Up-to-Dated Yes No No
Real Questions Yes No No
Explanation Yes No No
PDF + VCE Yes No No
Free VCE Simulator Yes No No
Instant Download Yes No No

2017 Ensurepass IT Certification PDF and VCE