01. Daylight saving time begins in the America/New_York zone at 02:00 on 2026-03-08.
Given:
import java.time.Duration;
import java.time.Period;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class Shift {
public static void main(String[] args) {
ZoneId zone = ZoneId.of("America/New_York");
ZonedDateTime start = ZonedDateTime.of(2026, 3, 7, 22, 0, 0, 0, zone);
ZonedDateTime byHours = start.plus(Duration.ofHours(24));
ZonedDateTime byDays = start.plus(Period.ofDays(1));
System.out.println(byHours.toLocalTime() + " " + Duration.between(start, byDays));
}
}
What is the result?
a) 22:00 PT24H
b) 23:00 PT24H
c) 22:00 PT23H
d) 23:00 PT23H
02. In the text block, the line containing red starts at column 15, green at column 17, blue at column 16, and the closing delimiter at column 13.
Given:
public class Palette {
public static void main(String[] args) {
String tb = """
red \s
green\
blue
""";
System.out.print(tb.replace(' ', '.').replace('\n', '|'));
}
}
What is the result?
a) ..red..|....green...blue|
b) red..|..green.blue|
c) ..red.|....green...blue|
d) Compilation fails.
03. Given:
enum Tier {
BRONZE(1),
SILVER(2) {
@Override
int bonus(int pts) { return pts + 90; }
},
GOLD(3);
private final int mult;
Tier(int mult) { this.mult = mult; }
int bonus(int pts) { return pts + mult; }
}
public class Rewards {
public static void main(String[] args) {
for (Tier t : Tier.values()) {
int r = switch (t) {
case BRONZE -> t.bonus(10);
case SILVER -> t.bonus(10) + t.ordinal();
case GOLD -> t.ordinal();
};
System.out.print(r + " ");
}
}
}
What is the result?
a) 11 13 2
b) 11 101 2
c) 11 102 3
d) Compilation fails.
04. These property files are on the classpath:
Labels.properties: greet=Hello, bye=Bye, title=Homepage
Labels_fr.properties: greet=Bonjour
Labels_fr_CA.properties: title=Accueil
Labels_de.properties: greet=Hallo, bye=Tschuss
Given:
Locale.setDefault(Locale.GERMANY);
ResourceBundle rb = ResourceBundle.getBundle("Labels", Locale.CANADA_FRENCH);
System.out.print(rb.getString("greet") + " " + rb.getString("bye") + " "
+ rb.getString("title"));
What is the result?
a) Bonjour Bye Accueil
b) Bonjour Bye Homepage
c) Bonjour Tschuss Accueil
d) A MissingResourceException is thrown.
05. A non-modular library is packaged as acme-json-parser-2.4.1.jar. Its manifest contains the entry Automatic-Module-Name: acme.json, and the JAR is placed on the module path.
The application module com.report calls com.acme.json.Parser from that JAR. Which directive in the com.report module declaration allows it to compile and run?
a) requires acme-json-parser;
b) requires acme.json.parser;
c) requires acme.json;
d) requires acme.json.parser.2.4.1;
06. Given:
class QuotaException extends Exception {
QuotaException(String m) { super(m); }
}
class HardQuotaException extends QuotaException {
HardQuotaException(String m) { super(m); }
}
abstract class Meter {
abstract int read() throws QuotaException;
}
public class GasMeter extends Meter {
// line n1
public static void main(String[] args) { }
}
Which method, inserted at line n1, allows the code to compile?
a) int read() throws HardQuotaException { return 0; }
b) int read() throws Exception { return 0; }
c) int read() throws HardQuotaException, InterruptedException { return 0; }
d) int read() { throw new QuotaException("over limit"); }
07. The directory work exists, is empty and is writable. Given:
Path dir = Path.of("work").resolve("a/b");
try {
Files.createDirectory(dir);
System.out.print("made ");
} catch (IOException e) {
System.out.print(e.getClass().getSimpleName() + " ");
}
Files.createDirectories(dir);
Path f = dir.resolve("n.txt");
Files.writeString(f, "ab");
Files.writeString(f, "cd", StandardOpenOption.APPEND);
Files.writeString(f, "e");
System.out.print(Files.readString(f));
What is the result?
a) made e
b) NoSuchFileException abcde
c) NoSuchFileException e
d) FileAlreadyExistsException e
08. Given:
interface Lamp {
default String glow() { return "lamp" + level(); }
private int level() { return 2; }
static Lamp basic() { return new Lamp() { }; }
}
interface Heater {
default String glow() { return "heat"; }
}
class Stove implements Lamp, Heater {
}
Which statement is true?
a) Stove must override glow(), and inside it Lamp.super.glow() returns lamp2.
b) Stove compiles as shown, and new Stove().glow() returns lamp2 at run time.
c) Adding public String glow() { return "s" + level(); } to Stove compiles.
d) With glow() overridden, Stove.basic() compiles and returns a new Lamp object.
09. Given the code fragment:
Stream<String> east = Stream.of("b,a", "c");
Stream<String> west = Stream.of("c", "a,d");
String out = Stream.concat(east, west)
.distinct()
.<String>mapMulti((s, sink) -> {
for (String t : s.split(",")) sink.accept(t);
})
.sorted(Comparator.reverseOrder())
.collect(Collectors.joining());
System.out.println(out);
What is the result?
a) dcba
b) dccbaa
c) Compilation fails.
d) dcbaa
10. The file Mode.java contains:
String mode = "no-arg main";
void main() {
IO.println(mode);
}
void main(String[] args) {
IO.println(args.length + " " + Arrays.toString(args));
main();
}
It is launched with java Mode.java red blue.
What is the result?
a) It prints no-arg main only.
b) It prints 2 [red, blue], then no-arg main.
c) Compilation fails at the call to main().
d) Compilation fails at Arrays.toString.