Vehicle with default methods start() and stop()Car that implements Vehicle and uses default methodsBike that implements Vehicle and overrides the start() methodCar and Bike and call their start() and stop() methodsVehicle with default methods start() and stop()Car that implements Vehicle and uses default methodsBike that implements Vehicle and overrides the start() methodCar and Bike and call their start() and stop() methodsVehicle with two methods: start() and stop(). Provide default implementations for both methods that print "Vehicle is starting" and "Vehicle is stopping" respectively.Use fun start() { println(...) } inside the interface to provide default behavior.
Car that implements the Vehicle interface. Do not override any methods so it uses the default start() and stop() implementations.Just write class Car : Vehicle and leave the body empty to use defaults.
Bike that implements the Vehicle interface. Override the start() method to print "Bike is starting differently" but keep the default stop() method.Use override fun start() { println(...) } inside Bike.
Car and Bike named myCar and myBike. Call start() and stop() on both instances. Print the output of these calls.Create val myCar = Car() and val myBike = Bike(). Then call start() and stop() on both.
What is the main purpose of providing a default implementation in a Kotlin interface?
interface Example { fun greet() { println("Hello") } }
Which of the following is the correct syntax for a Kotlin interface with a default implementation of a function fun info()?
What will be the output of the following Kotlin code?
interface Printer {
fun print() { println("Printing from interface") }
}
class Document : Printer {
override fun print() { println("Printing from Document") }
}
fun main() {
val doc: Printer = Document()
doc.print()
}Identify the error in this Kotlin code snippet:
interface Logger {
fun log() { println("Logging") }
}
class FileLogger : Logger {
fun log() { println("File logging") }
}Given this Kotlin interface and classes, what will be the output when main() runs?
interface Speaker {
fun speak() { println("Speaking from Speaker") }
}
class Person : Speaker
class Robot : Speaker {
override fun speak() { println("Speaking from Robot") }
}
fun main() {
val list: List<Speaker> = listOf(Person(), Robot())
for (item in list) {
item.speak()
}
}Pass the test and this pattern moves unknown