Complete the code to declare a class that implements two interfaces.
interface A {
fun foo()
}
interface B {
fun bar()
}
class MyClass : [1] {
override fun foo() {
println("foo")
}
override fun bar() {
println("bar")
}
}In Kotlin, to implement multiple interfaces, separate them with commas.
Complete the code to override the method from interface A.
interface A {
fun greet(): String
}
class Person : A {
override fun [1](): String {
return "Hello"
}
}The method name must match exactly the one declared in the interface.
Fix the error in the class declaration to implement both interfaces A and B.
interface A {
fun foo()
}
interface B {
fun bar()
}
class Sample : [1] {
override fun foo() {}
override fun bar() {}
}Interfaces must be separated by commas in Kotlin class declarations.
Fill both blanks to complete the class declaration and method override.
interface X {
fun action()
}
interface Y {
fun action()
}
class Combined : [1] {
override fun [2]() {
println("Action performed")
}
}Separate interfaces with commas and override the method named 'action'.
Fill all three blanks to implement two interfaces and override their methods correctly.
interface First {
fun firstMethod()
}
interface Second {
fun secondMethod()
}
class MultiImpl : [1] {
override fun [2]() {
println("First method")
}
override fun [3]() {
println("Second method")
}
}Separate interfaces with commas and override both methods with their exact names.
