When it comes to classes in Java, there are two types: final and non-final. A final class cannot be inherited or extended, as its code is locked in place, while a non-final class can be extended to create a subclass. This allows a developer to add new features and behavior to the existing class without affecting the parent code.   However, attempting to inherit a final class will result in an error message as the compiler will not allow it. In many cases, making a class final is done for security purposes; if someone tries to extend the existing code, they won't be able to do so unless they have explicit permission from the developer. In other cases, inheritance just isn't necessary; either way, you cannot inherit from a final class.   To prevent this from happening, developers should be sure to make any classes that do not need to be inherited into final classes if possible. Doing this ensures that your code remains safe and secure from third parties trying to access or modify it without permission.