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 51

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?

 

A.

Replace line n1 with:

IntFunction<UnaryOperator> inFu = x -> y -> x*y;

B.

Replace line n1 with:

IntFunction<IntUnaryOperator> inFu = x -> y -> x*y;

C.

Replace line n1 with:

BiFunction<IntUnaryOperator> inFu = x -> y -> x*y;

D.

Replace line n2 with:

IntStream newStream = stream.map(inFu.applyAsInt (10));

 

Correct Answer: D

 

 

QUESTION 52

Given:

 

clip_image001

 

Which two classes use the shape class correctly?

 

clip_image003

 

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

F.

Option F

 

Correct Answer: BE

Explanation:

When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class (E). However, if it does not, then the subclass must also be declared abstract (B). Note: An abstract class is a class that is declared abstract–it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.

 

 

QUESTION 53

Given the code fragment:

 

Path source = Paths.get (“/data/december/log.txt”);

 

Path destination = Paths.get(“/data”);

 

Files.copy (source, destination);

 

and assuming that the file /data/december/log.txt is accessible and contains:

 

10-Dec-2014 ?Executed successfully

 

What is the result?

 

A.

A file with the name log.txt is created in the /data directory and the content of the /data/december/log.txt file is copied to it.

B.

The program executes successfully and does NOT change the file system.

C.

A FileNotFoundException is thrown at run time.

D.

A FileAlreadyExistsException is thrown at run time.

 

Correct Answer: B

 

 

QUESTION 54

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.

 

Correct Answer: A

 

 

QUESTION 55

Given the code fragment:

 

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

 

UnaryOperator<Double> uo = s -> s +10.0;

 

codes.replaceAll(uo);

 

codes.forEach(c -> System.out.println(c));

 

What is the result?

 

A.

20.0

30.0

B.

10

C.

A compilation error occurs.

D.

A NumberFormatException is thrown at run time.

 

Correct Answer: A

 

 

QUESTION 56

Given:

 

public class Canvas implements Drawable {

 

public void draw () { }

 

}

 

public abstract class Board extends Canvas { }

 

public class Paper extends Canvas {

 

protected void draw (int color) { }

 

}

 

public class Frame extends Canvas implements Drawable {

 

public void resize () { }

 

}

 

public interface Drawable {

 

public abstract void draw ();

 

}

 

Which statement is true?

A.

Board does not compile.

B.

Paper does not compile.

C.

Frame does not compile.

D.

Drawable does not compile.

E.

All classes compile successfully.

 

Correct Answer: B

 

 

QUESTION 57

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?

 

A.

The program prints several values that total 55.

B.

The program prints 55.

C.

A compilation error occurs at line n1.

D.

The program prints several values whose sum exceeds 55.

 

Correct Answer: C

 

 

QUESTION 58

Given the code fragment:

 

public class FileThread implements Runnable {

 

String fName;

&nb
sp;

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?

 

A.

The program throws a runtime exception at line n2.

B.

The program prints files names concurrently.

C.

The program prints files names sequentially.

D.

A compilation error occurs at line n1.

 

Correct Answer: A

 

 

QUESTION 59

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()

 

.forEach(System.out::println); //line n1

 

} catch (IOException e) {

 

System.out.println(“Exception”);

 

}

 

}

 

);

 

What is the result?

 

A.

The program prints the content of data.txt file.

B.

The program prints:

Exception

<<The content of the data.txt file>>

Exception

C.

A compilation error occurs at line n1.

D.

The program prints the content of the three files.

 

Correct Answer: D

 

 

QUESTION 60

Given the code fragment:

 

Path path1 = Paths.get(“/app/./sys/”);

 

Path res1 = path1.resolve(“log”);

 

Path path2 = Paths.get(“/server/exe/”);

 

Path res1 = path1.resolve(“/readme/”);

 

System.out.println(res1);

 

System.out.println(res2);

 

What is the result?

 

A.

/app/sys/log

/readme/server/exe

B.

/app/log/sys

/server/exe/readme

C.

/app/./sys/log

/readme

D.

/app/./sys/log

/server/exe/readme

 

Correct Answer: D

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