There is an interface Flying that has a method getHeight returning the height of flying in meters. Add and implement a default method getHeightInKm that returns height of flying in kilometers.
Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingClass hierarchiesInterfaces and abstract classes
Default methods
Add new default method
Report a typo
Sample Input 1:
1000Sample Output 1:
1Write a program in Java 17
interface Flying {
// returns height of flying in meters
int getHeight();
// implements a default method getHeightInKm that returns height of flying in km as int type
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.