ADC With Mounir (@ADCWithMounir) header
ADC With Mounir (@ADCWithMounir) profile picture

Architect → Design → Code. The full journey of a Java engineer. YouTube https://teapawt.net/t.co/AZ4ghe5SNN GitHub https://teapawt.net/t.co/5tRtWJlH0z

Paris, Ile-de-France
Joined September 2026
A record with no components at all. Most developers would bet it doesn't compile.
1
Four constructors for one record. Two of them compile. Pick TWO. Answer in the replies in one hour.
1
6
Answers: B and D A: false. A non-canonical constructor must call this(...) first. B: true. It calls this(n, 9.99) first. C: false. No this(...), and it assigns a final field. D: true. A compact constructor can reassign a parameter. Full explanation on my YouTube channel.
4
A HashSet never scans every element to find a duplicate. It needs only two method calls.
2
11
Java, Spring Boot, Spring AI, AI agents. Plus system design and clean code. If that's your world, let's connect. I share something new every day.
2
3
42
"Up", "up", "Up" again, into a HashSet. Three add results and a size. What prints? Answer in the replies in one hour.
1
1
13
Answer: A (true true false 2) Strings are compared with equals, and equals is case sensitive: "up" is a new element. Only the second "Up" is a duplicate, so add returns false and the size stays 2. Full explanation on my YouTube channel.
1
3
Two predicates in your code. You need three more combinations. You don't write a single new rule.
1
8
Four lambdas for one Predicate. Only one compiles. Answer in the replies in one hour.
1
7
Answer: C (var m) is a legal single parameter, and m.hd() returns the boolean. A: braces need return and a semicolon. B: test() takes one parameter, and the styles are mixed. D: a typed parameter needs parentheses. Full explanation on my YouTube channel.
7
A third ride type joins the enum. Everything compiles. The six-seat van now shows up as a Comfort car with four seats. How would you close the menu? Your fix in the replies.
1
6
The fix: replace the type code with an interface. RideOption gives label, seats and fare. Economy, Comfort and Xl each implement it. The menu just asks every option. A new ride type is now a new class. The menu never changes.
4
Three objects. The static block runs once.
1
8
Two classes, static and instance blocks, two new Series(). What does it print? Answer in the replies in one hour.
1
9
Answer: B (ADBCEFBCEF) The classes are set up first, parent first: A then D, and only once. Each new Series builds the Content part (B, C), then the Series part (E, F). The second object skips A and D. Full explanation on my YouTube channel.
2
Validate a record without rewriting its constructor. The compact constructor runs in 3 steps.
6
A static field, a private field, and a compact constructor. Which lines break this record? Answer in the replies in one hour.
1
1
2
27
Answer: C (lines 3 and 6) Line 2 is fine: records can have static fields. Line 3: no instance field in a record body, even private. Line 6: this.title is final, a compact constructor can't assign it. Write title = title.strip(); Full explanation on my YouTube channel.
6
A TreeSet of records. It compiles, then fails on the very first add. Your fix in the replies.
1
1
37
The fix: make Show implement Comparable<Show>, or give the set a Comparator: new TreeSet<>(Comparator.comparing(Show::title)) A TreeSet must compare elements to sort them. Without a way to compare, it throws ClassCastException.
1
13