Define and implement a default method print in the Printer interface to make code in the main method print the text This is a default message. Do not change either Main or ConsolePrinter classes.
Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingClass hierarchiesInterfaces and abstract classes
Default methods
Implement a default method
Report a typo
Write a program in Java 17
// do not change code below
class Main {
public static void main(String... args) {
Printer printer = new ConsolePrinter();
printer.print(); // prints: This is a default message
}
}
class ConsolePrinter implements Printer {
}
interface Printer {
// define and implement default method print to make code above print the message: "This is a default message"
}
___
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.