We can also use classes and interfaces written in Kotlin to extend and implement new classes in Java. Here, we've defined a new Programmer class in Java that inherits from the previously defined Person Kotlin class:
public class Programmer extends Person {
private String preferredLanguage;
public Programmer(String firstName, String lastName,
String preferredLanguage) {
super(firstName, lastName);
this.preferredLanguage = preferredLanguage;
}
}
From this example, we can see that we can extend Person like any other Java class. In fact, to the consuming code it's not obvious whether Person is written in Kotlin or Java. Additionally, because both languages are being compiled to common JVM bytecode, there is no underlying performance penalty in declaring a class using a different language than its base class.