Given:
java
String colors = "red\n" +
"green\n" +
"blue\n";
Which text block can replace the above code?
Given:
java
Object input = 42;
String result = switch (input) {
case String s -> "It's a string with value: " + s;
case Double d -> "It's a double with value: " + d;
case Integer i -> "It's an integer with value: " + i;
};
System.out.println(result);
What is printed?
Given:
java
public class ThisCalls {
public ThisCalls() {
this(true);
}
public ThisCalls(boolean flag) {
this();
}
}
Which statement is correct?
What do the following print?
java
public class DefaultAndStaticMethods {
public static void main(String[] args) {
WithStaticMethod.print();
}
}
interface WithDefaultMethod {
default void print() {
System.out.print("default");
}
}
interface WithStaticMethod extends WithDefaultMethod {
static void print() {
System.out.print("static");
}
}
Given:
java
public class Test {
class A {
}
static class B {
}
public static void main(String[] args) {
// Insert here
}
}
Which three of the following are valid statements when inserted into the given program?
Given:
java
final Stream
Files.readAllLines(Paths.get("orders.csv"));
strings.skip(1)
.limit(2)
.forEach(System.out::println);
And that the orders.csv file contains:
mathematica
OrderID,Customer,Product,Quantity,Price
1,Kylian Mbappé,Keyboard,2,25.50
2,Teddy Riner,Mouse,1,15.99
3,Sebastien Loeb,Monitor,1,199.99
4,Antoine Griezmann,Headset,3,45.00
What is printed?
What does the following code print?
java
import java.util.stream.Stream;
public class StreamReduce {
public static void main(String[] args) {
Stream
System.out.print(stream.reduce(String::concat));
}
}