Problems
Use the following problems to test your programming prowess in manipulating sealed classes and hidden classes in Java. I strongly encourage you to give each problem a try before you turn to the solutions and download the example programs:
- Creating an electrical panel (hierarchy of classes): Write the stub of a Java application that shapes an electrical panel. You can assume that the electrical panel is made of several types of electrical components (for instance, resistors, transistors, and so on), and electrical circuits (for instance, parallel circuits, series circuits, and so on).
- Closing the electrical panel before JDK 17: Use the Java features (for instance, the
final
keyword and package-private hacks) to close this hierarchy (close to extension). - Introducing JDK 17 sealed classes: Provide a brief introduction to JDK 17 sealed classes. Exemplify how to write closed hierarchies in a single source file via sealed classes.
- Introducing the permits...