Implementing default method in Java interface

Report a typo

Given a snippet of an interface `A` in Java with a default method `print()`, and a class `B` that implements interface `A`, you need to fill in the blanks in the code to correctly implement the functionality. Additionally, there's a `main` method in class `Main`, which creates an instance of class `B` and calls the `print()` method. Ensure the code compiles and runs without errors, displaying the expected output.

Fill in the gaps with the relevant elements
 A {
      print() {
        System.out.println("Default method from interface A.");
    }
}

class B  A {}

public class Main {
    public static void main(String[] args) {
        B b = new B();
        b.print();
    }
}
extendsnulldefaultinterfacedefaultedvoidclassimplements
___

Create a free account to access the full topic