Given:
java
void verifyNotNull(Object input) {
boolean enabled = false;
assert enabled = true;
assert enabled;
System.out.println(input.toString());
assert input != null;
}
When does the given method throw a NullPointerException?
Given:
java
List
integers.stream()
.peek(System.out::print)
.limit(2)
.forEach(i -> {});
What is the output of the given code fragment?
Given:
java
var sList = new CopyOnWriteArrayList
Which of the following statements is correct?
Given:
java
String s = " ";
System.out.print("[" + s.strip());
s = " hello ";
System.out.print("," + s.strip());
s = "h i ";
System.out.print("," + s.strip() + "]");
What is printed?
Given:
java
public class Test {
public static void main(String[] args) throws IOException {
Path p1 = Path.of("f1.txt");
Path p2 = Path.of("f2.txt");
Files.move(p1, p2);
Files.delete(p1);
}
}
In which case does the given program throw an exception?
Which of the following methods of java.util.function.Predicate aredefault methods?
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?
Given:
java
Deque
deque.offer(1);
deque.offer(2);
var i1 = deque.peek();
var i2 = deque.poll();
var i3 = deque.peek();
System.out.println(i1 + " " + i2 + " " + i3);
What is the output of the given code fragment?
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?