0
0
Goprogramming~5 mins

Function execution flow in Go - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What happens first when a function is called in Go?
The program jumps to the function's code and starts executing from the first line inside the function.
Click to reveal answer
beginner
What is the role of the return statement in a function?
It ends the function execution and optionally sends a value back to where the function was called.
Click to reveal answer
intermediate
How does Go handle multiple return values in a function?
Go functions can return multiple values by listing them in the function signature and the return statement.
Click to reveal answer
beginner
What happens if a function does not have a return statement?
If the function's return type is void (no return), it simply finishes execution and control goes back to the caller.
Click to reveal answer
intermediate
Explain the flow when a function calls another function inside it.
The first function pauses, the called function runs completely, then control returns to the first function to continue.
Click to reveal answer
What does the Go program do immediately after a function finishes executing?
ATerminates the program
BStarts executing the main function again
CReturns control to the point where the function was called
DSkips to the next function in the file
Which keyword is used to send a value back from a function in Go?
Areturn
Bsend
Coutput
Dyield
If a function calls another function, what happens to the first function?
AIt continues running in parallel
BIt pauses until the called function finishes
CIt ends immediately
DIt restarts from the beginning
Can a Go function return more than one value?
ANo, only one value is allowed
BOnly if it returns a slice
COnly if it uses pointers
DYes, by listing multiple return types
What happens if a function with no return type reaches the end of its code?
AIt ends and returns control to the caller
BIt causes a compile error
CIt waits for a return statement
DIt restarts automatically
Describe the step-by-step flow when a Go function is called and then returns a value.
Think about what happens from the moment you call the function until you get the result.
You got /5 concepts.
    Explain how Go handles a function that calls another function inside it.
    Imagine you ask a friend to do something before you continue your task.
    You got /4 concepts.