 In Java, the codice_5 keyword can be used to prevent a class from being subclassed.The doctrine of composition over inheritance advocates implementing has-a relationships using composition instead of inheritance.For example, instead of inheriting from class Person, class Employee could give each Employee object an internal Person object, which it then has the opportunity to hide from external code even if class Person has many public attributes or methods.