Last active
October 23, 2023 13:16
-
-
Save sasssass/73b99f6bba3feec6650a11cf37d2071a to your computer and use it in GitHub Desktop.
polymorphism.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open class Parent() { | |
open fun doSth() { | |
print("I'm Parent") | |
} | |
} | |
class Child() : Parent() { | |
override fun doSth() { | |
print("I'm Child") | |
} | |
} | |
fun main() { | |
val obj : Parent = Child() | |
obj.doSth() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment