Java / Java 21 Coding Standards Interview Questions
What are the standard naming conventions for classes and interfaces in Java 21?
Classes and interfaces are named in UpperCamelCase, using nouns or noun phrases that describe what the type represents, such as OrderProcessor or PaymentGateway. This convention is unchanged in Java 21, but it now also applies to two newer type declarations: records and sealed types.
A record should still be named as a noun, for example Point or OrderLine, since it represents a value, not an action. A sealed interface is usually named after the concept it constrains, such as Shape, with its permitted subtypes named as concrete nouns like Circle and Square.
Interfaces are not prefixed with I in Java style guides; an adjective ending in -able is preferred when the interface describes a capability, for example Comparable or Closeable.
More Related questions...