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 71

Given:

 

clip_image002

 

What is the result?

 

A.

0

Done

B.

First Exception

Done

C.

Second Exception

D.

Done

Third Exception

E.

Third Exception

 

Correct Answer: B

 

 

QUESTION 72

Which two reasons should you use interfaces instead of abstract classes?

 

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.

 

Correct Answer: AE

Explanation:

http://www.programmerinterview.com/index.php/java-questions/interface-vs-abstract-class/

 

 

QUESTION 73

Given:

 

clip_image004

 

What is the result?

 

A.

10 : 22 : 20

B.

10 : 22 : 22

C.

10 : 22 : 6

D.

10 : 30 : 6

 

Correct Answer: B

 

 

QUESTION 74

Given the code fragment:

 

clip_image005

 

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

 

Correct Answer: B

 

 

QUESTION 75

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?

 

A.

List<String> fc = Files.list(file);

fc.stream().forEach (s – > System.out.println(s));

B.

Stream<String> fc = Files.readAllLines (file);

fc.forEach (s – > System.ou
t.println(s));

C.

List<String> fc = readAllLines(file);

fc.stream().forEach (s – > System.out.println(s));

D.

Stream<String> fc = Files.lines (file);

fc.forEach (s – > System.out.println(s));

 

Correct Answer: B

 

 

QUESTION 76

Given that /green.txt and /colors/yellow.txt are accessible, and the code fragment:

 

Path source = Paths.get(“/green.txt);

 

Path target = Paths.get(“/colors/yellow.txt);

 

Files.move(source, target, StandardCopyOption.ATOMIC_MOVE);

 

Files.delete(source);

 

Which statement is true?

 

A.

The green.txt file content is replaced by the yellow.txt file content and the yellow.txt file is deleted.

B.

The yellow.txt file content is replaced by the green.txt file content and an exception is thrown.

C.

The file green.txt is moved to the /colors directory.

D.

A FileAlreadyExistsException is thrown at runtime.

 

Correct Answer: D

 

 

QUESTION 77

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

 

Correct Answer: C

 

QUESTION 78

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?

 

A.

A compilation error occurs.

B.

d b e z j

C.

j z e b d

D.

z b d e j

 

Correct Answer: C

 

 

QUESTION 79

Given:

 

public interface Moveable<Integer> {

 

public default void walk (Integer distance) {System.out.println(“Walking”);)

public void run(Integer distance);

 

}

 

Which statement is true?

 

A.

Moveable can be used as below:

Moveable<Integer> animal = n – > System.out.println(“Running” + n);

animal.run(100);

animal.walk(20);

B.

Moveable can be used as below:

Moveable<Integer> animal = n – > n + 10;

animal.run(100);

animal.walk(20);

C.

Moveable can be used as below:

Moveable animal = (Integer n) – > System.out.println(n);

animal.run(100);

Moveable.walk(20);

D.

Movable cannot be used in a lambda expression.

 

Correct Answer: B

 

 

QUESTION 80

public class ForTest {

 

public static void main(String[] args) {

 

int[] arrar = {1,2,3};

 

for ( foo ) {

 

}

 

}

 

}

 

Which three are valid replacements for foo so that the program will compiled and run?

 

A.

int i: array

B.

int i = 0; i < 1; i++

C.

;;

D.

; i < 1; i++

E.

; i < 1;

 

Correct Answer: ABC

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