Complete the code to make the class extendable.
open class Vehicle { fun drive() { println("Driving") } } class Car : [1] Vehicle() {}
In Kotlin, to allow a class to be inherited, it must be declared as open.
Complete the code to allow the method to be overridden.
open class Animal { [1] fun sound() { println("Some sound") } }
Methods must be marked open to be overridden in subclasses.
Fix the error in the subclass method overriding.
open class Bird { open fun fly() { println("Flying") } } class Eagle : Bird() { override fun [1]() { println("Eagle flying") } }
The method name in the subclass must match the open method in the superclass to override it.
Fill both blanks to create an open class with an open method.
[1] class Shape { [2] fun draw() { println("Drawing shape") } }
Both the class and the method must be marked open to allow inheritance and overriding.
Fill all three blanks to override an open method in a subclass.
open class Printer { open fun [1]() { println("Printing document") } } class ColorPrinter : Printer() { override fun [2]() { println([3]) } }
The method name must match in both classes, and the subclass method can provide a different implementation.
