Answer the question
In order to leave comments, you need to log in
Why specify the interface type when creating a class object?
Screenshot code:
interface Do {
fun doing ()
}
class Teacher() : Do {
override fun doing () {
println("Im teaching students..")
}
}
class Programmer() : Do {
override fun doing() {
println("Im writing programs..")
}
}
fun main() {
val person1: Do = Programmer()
person1.doing()
val person2: Programmer = Programmer()
person1.doing()
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question