Junior — Senior
Analysis of the behavior of the SpecialFunction class
livecode
Task condition
In the example, a class SpecialFunction is declared, implementing a functional interface with no parameters and no return value. When it is invoked, the string "Invoked from an instance." is printed to the console. It is required to predict what text will appear in the output after executing the main function.
class SpecialFunction : () -> Unit {
override fun invoke() {
println("Invoked from an instance.")
}
}
fun main() {
try { SpecialFunction()() }
catch (ex: Exception) { println("An error occurred") }
}