Given: java
String textBlock = """ j
a t v s a """;
System.out.println(textBlock.length()); What is the output?
Correct Answer:B
Given: java
public class Test { static int count;
synchronized Test() { count++;
}
public static void main(String[] args) throws InterruptedException { Runnable task = Test::new;
Thread t1 = new Thread(task); Thread t2 = new Thread(task);
t1.start();
t2.start();
t1.join();
t2.join(); System.out.println(count);
}
}
What is the given program's output?
Correct Answer:E
Given: java
Stream
System.out.println(result);
What is the output of this code fragment?
Correct Answer:F
Which of the following suggestions compile?(Choose two.)
Correct Answer:AD
Given: java
interface Calculable { long calculate(int i);
}
public class Test {
public static void main(String[] args) { Calculable c1 = i -> i + 1; // Line 1 Calculable c2 = i -> Long.valueOf(i); // Line 2
Calculable c3 = i -> { throw new ArithmeticException(); }; // Line 3
}
}
Which lines fail to compile?
Correct Answer:G