Go Interview Questions and Answers For Freshers Part-3
21.What is the default way of passing parameters to a function?
By default, Go uses call by value to pass arguments. In general, this means that code within a function cannot alter the arguments used to call the function and above mentioned example while calling max() function used the same method.
22.What do you mean by function as value in Go?
Go programming language provides flexibility to create functions on the fly and use them as values. We can set a variable with a function definition and use it as parameter to a function.
23.What are the function closures?
Functions closure are anonymous functions and can be used in dynamic programming.
24.What are methods in Go?
Go programming language supports special types of functions called methods. In method declaration syntax, a “receiver” is present to represent the container of the function. This receiver can be used to call function using “.” operator.
25.What is default value of a local variable in Go?
A local variable has default value as it corresponding 0 value.
26.What is default value of a global variable in Go?
A global variable has default value as it corresponding 0 value.
27.What is default value of a pointer variable in Go?
Pointer is initialized to nil.
28.Explain the purpose of the function Printf().
Prints the formatted output.
29.What is lvalue and rvalue?
The expression appearing on right side of the assignment operator is called as rvalue. Rvalue is assigned to lvalue, which appears on left side of the assignment operator. The lvalue should designate to a variable not a constant.
30.What is the difference between actual and formal parameters?
The parameters sent to the function at calling end are called as actual parameters while at the receiving of the function definition called as formal parameters.