Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

Go Interview Questions and Answers For Freshers Part-4

Be First!

Go31.What is the difference between variable declaration and variable definition?
Declaration associates type to the variable whereas definition gives the value to the variable.

32.Explain modular programming.
Dividing the program in to sub programs (modules/function) to achieve the given task is modular approach. More generic functions definition gives the ability to re-use the functions, such as built-in library functions.

33.What is a token?
A Go program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol.

34.Which key word is used to perform unconditional branching?
goto

35.What is an array?
Array is collection of similar data items under a common name.

36.What is a nil Pointers in Go?
Go compiler assign a Nil value to a pointer variable in case you do not have exact address to be assigned. This is done at the time of variable declaration. A pointer that is assigned nil is called a nil pointer. The nil pointer is a constant with a value of zero defined in several standard libraries.

37.What is a pointer on pointer?
It’s a pointer variable which can hold the address of another pointer variable. It de-refers twice to point to the data held by the designated pointer variable.

var a int
var ptr *int
var pptr **int
a = 3000
ptr = &a
pptr = &ptr
fmt.Printf(“Value available at **pptr = %d\n”, **pptr)
Therefore ‘a’ can be accessed by **pptr.

38.What is structure in Go?
Structure is another user defined data type available in Go programming, which allows you to combine data items of different kinds.

39.How to define a structure in Go?
To define a structure, you must use type and struct statements. The struct statement defines a new data type, with more than one member for your program. type statement binds a name with the type which is struct in our case.

The format of the struct statement is this −

type struct_variable_type struct {
member definition;
member definition;

member definition;
}
40.What is slice in Go?
Go Slice is an abstraction over Go Array. As Go Array allows you to define type of variables that can hold several data items of the same kind but it do not provide any inbuilt method to increase size of it dynamically or get a sub-array of its own. Slices covers this limitation. It provides many utility functions required on Array and is widely used in Go programming.

(162)

Previous
Next

Leave a Reply