The order of stack frames in the call stack

Report a typo

There is a small program with three methods:

public class Main {
    public static void main(String args[]) {
        printLine(repeat("Hello!"));
    }
    
    public static void printLine(String str) {
        System.out.println(str);
    }
    
    public static String repeat(String s) {
        return s + s;
    }
}

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

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

Create a free account to access the full topic