Complete the code to declare an interface with a default implementation for the greet function.
interface Greeter {
fun greet() {
println([1])
}
}Complete the code to implement the Greeter interface and override the greet function.
class FriendlyGreeter : Greeter { override fun greet() { println([1]) } }
Fix the error in the code to call the default greet implementation from the interface inside the override.
class PoliteGreeter : Greeter { override fun greet() { [1].greet() println("Have a nice day!") } }
Fill both blanks to define an interface with a default method and a class that calls it.
interface Speaker {
fun speak() {
println([1])
}
}
class Person : Speaker {
fun sayHello() {
[2].speak()
}
}Fill all three blanks to create an interface with a default method, a class overriding it, and calling both versions.
interface Animal {
fun sound() {
println([1])
}
}
class Dog : Animal {
override fun sound() {
println([2])
[3].sound()
}
}