Free 1z0-830 Exam Dumps

Question 11

Given: java
try (FileOutputStream fos = new FileOutputStream("t.tmp"); ObjectOutputStream oos = new ObjectOutputStream(fos)) { fos.write("Today");
fos.writeObject("Today"); oos.write("Today"); oos.writeObject("Today");
} catch (Exception ex) {
// handle exception
}
Which statement compiles?

Correct Answer:D

Question 12

Given: java
Optional o1 = Optional.empty(); Optional o2 = Optional.of(1); Optional o3 = Stream.of(o1, o2)
.filter(Optional::isPresent)
.findAny()
.flatMap(o -> o); System.out.println(o3.orElse(2));
What is the given code fragment's output?

Correct Answer:A

Question 13

Which StringBuilder variable fails to compile? java
public class StringBuilderInstantiations {
public static void main(String[] args) { var stringBuilder1 = new StringBuilder();
var stringBuilder2 = new StringBuilder(10);
var stringBuilder3 = new StringBuilder("Java");
var stringBuilder4 = new StringBuilder(new char[]{'J', 'a', 'v', 'a'});
}
}

Correct Answer:B

Question 14

Given: java
StringBuilder result = Stream.of("a", "b")
.collect(
() -> new StringBuilder("c"), StringBuilder::append,
(a, b) -> b.append(a)
);
System.out.println(result);
What is the output of the given code fragment?

Correct Answer:F

Question 15

Given: java
public class Versailles { int mirrorsCount;
int gardensHectares;
void Versailles() { // n1 this.mirrorsCount = 17;
this.gardensHectares = 800;
System.out.println("Hall of Mirrors has " + mirrorsCount + " mirrors."); System.out.println("The gardens cover " + gardensHectares + " hectares.");
}
public static void main(String[] args) { var castle = new Versailles(); // n2
}
}
What is printed?

Correct Answer:D