Have you tried to compile that code ?
"package exists in another module: java.base"
"cannot find symbol
symbol: class Random
location: class java.util.Example"...
Also see the JLS https://docs.oracle.com/javase/specs/jls/se17/html/jls-6.html#jls-6.6 (That's the case in the same package)
Also very important:
https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html
Quote from it: "The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package." ..
The case what you have shown with your "fictional" example is the part "within it's own package.." ...