Given:
java
package com.vv;
import java.time.LocalDate;
public class FetchService {
public static void main(String[] args) throws Exception {
FetchService service = new FetchService();
String ack = service.fetch();
LocalDate date = service.fetch();
System.out.println(ack + " the " + date.toString());
}
public String fetch() {
return "ok";
}
public LocalDate fetch() {
return LocalDate.now();
}
}
What will be the output?
Given:
java
Period p = Period.between(
LocalDate.of(2023, Month.MAY, 4),
LocalDate.of(2024, Month.MAY, 4));
System.out.println(p);
Duration d = Duration.between(
LocalDate.of(2023, Month.MAY, 4),
LocalDate.of(2024, Month.MAY, 4));
System.out.println(d);
What is the output?
Given:
java
var array1 = new String[]{ "foo", "bar", "buz" };
var array2[] = { "foo", "bar", "buz" };
var array3 = new String[3] { "foo", "bar", "buz" };
var array4 = { "foo", "bar", "buz" };
String array5[] = new String[]{ "foo", "bar", "buz" };
Which arrays compile? (Select 2)
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:
var cabarets = new TreeMap<>();
cabarets.put(1, "Moulin Rouge");
cabarets.put(2, "Crazy Horse");
cabarets.put(3, "Paradis Latin");
cabarets.put(4, "Le Lido");
cabarets.put(5, "Folies Bergère");
System.out.println(cabarets.subMap(2, true, 5, false));
What is printed?
Given:
java
StringBuffer us = new StringBuffer("US");
StringBuffer uk = new StringBuffer("UK");
Stream
String output = stream.collect(Collectors.joining("-", "=", ""));
System.out.println(output);
What is the given code fragment's output?
Given:
java
var deque = new ArrayDeque<>();
deque.add(1);
deque.add(2);
deque.add(3);
deque.add(4);
deque.add(5);
System.out.print(deque.peek() + " ");
System.out.print(deque.poll() + " ");
System.out.print(deque.pop() + " ");
System.out.print(deque.element() + " ");
What is printed?
Given:
java
DoubleStream doubleStream = DoubleStream.of(3.3, 4, 5.25, 6.66);
Predicate
System.out.println(doubleStream.anyMatch(doublePredicate));
What is printed?