Arrange the stack frames

Report a typo

There is a small program with three functions:

fun repeat(s: String): String {
    return s + s
}

fun printLine(str: String) {
    println(str)
}

fun main() {
    printLine(repeat("Hello!"))
}

Sort the lines in the order, in which stack frames will be pushed and removed to/from the call stack when running the main function. The first operation should be on the top.

Put the items in the correct order
push main frame
push repeat frame
push printLine frame
pop printLine frame
pop main frame
pop repeat frame
___

Create a free account to access the full topic