This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What Are Interfaces In Go? |
|
Answer» Go programming provides another data TYPE CALLED interfaces which represents a set of method signatures. STRUCT data type IMPLEMENTS these interfaces to have method definitions for the method signature of the interfaces. Go programming provides another data type called interfaces which represents a set of method signatures. struct data type implements these interfaces to have method definitions for the method signature of the interfaces. |
|
| 2. |
What Is Type Casting In Go? |
|
Answer» Type casting is a way to convert a variable from one data type to another data type. For EXAMPLE, if you want to store a long value into a simple INTEGER then you can type cast long to int. You can convert VALUES from one type to another using the cast OPERATOR as following: type_name(expression) Type casting is a way to convert a variable from one data type to another data type. For example, if you want to store a long value into a simple integer then you can type cast long to int. You can convert values from one type to another using the cast operator as following: type_name(expression) |
|
| 3. |
How To Delete An Entry From A Map In Go? |
|
Answer» DELETE() function is used to delete an ENTRY from the map. It requires map and corresponding KEY which is to be DELETED. delete() function is used to delete an entry from the map. It requires map and corresponding key which is to be deleted. |
|
| 4. |
How To Create A Map In Go? |
|
Answer» You MUST use MAKE function to create a map. /* declare a variable, by default map will be nil*/ You must use make function to create a map. /* declare a variable, by default map will be nil*/ |
|
| 5. |
What Are Maps In Go? |
|
Answer» GO provides another important data type map which maps UNIQUE KEYS to values. A key is an object that you use to retrieve a value at a later date. Given a key and a value, you can strore the value in a Map object. After value is STORED, you can retrieve it by using its key. Go provides another important data type map which maps unique keys to values. A key is an object that you use to retrieve a value at a later date. Given a key and a value, you can strore the value in a Map object. After value is stored, you can retrieve it by using its key. |
|
| 6. |
What Is Range In Go? |
|
Answer» The range KEYWORD is used in for loop to iterate over items of an array, SLICE, channel or MAP. With array and slices, it returns the index of the item as integer. With maps, it returns the key of the NEXT key-value pair. The range keyword is used in for loop to iterate over items of an array, slice, channel or map. With array and slices, it returns the index of the item as integer. With maps, it returns the key of the next key-value pair. |
|
| 7. |
How To Get A Sub-slice Of A Slice? |
|
Answer» SLICE allows lower-bound and UPPER bound to be SPECIFIED to GET the subslice of it using[lower-bound:upper-bound]. Slice allows lower-bound and upper bound to be specified to get the subslice of it using[lower-bound:upper-bound]. |
|
| 8. |
What Is The Difference Between Len() And Cap() Functions Of Slice In Go? |
|
Answer» LEN() FUNCTION returns the ELEMENTS presents in the slice where CAP() function returns the capacity of slice as how many elements it can be accomodate. len() function returns the elements presents in the slice where cap() function returns the capacity of slice as how many elements it can be accomodate. |
|
| 9. |
How To Get The Count Of Elements Present In A Slice? |
|
Answer» LEN() function returns the elements presents in the SLICE. len() function returns the elements presents in the slice. |
|
| 10. |
How To Define A Slice In Go? |
|
Answer» To DEFINE a slice, you can DECLARE it as an array without specifying SIZE or use make function to CREATE the one. var numbers []int /* a slice of unspecified size */ To define a slice, you can declare it as an array without specifying size or use make function to create the one. var numbers []int /* a slice of unspecified size */ |
|
| 11. |
What Is Slice In Go? |
|
Answer» 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. 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. |
|
| 12. |
How To Define A Structure In Go? |
|
Answer» 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 { 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 { |
|
| 13. |
What Is Structure In Go? |
|
Answer» STRUCTURE is another user defined data type AVAILABLE in GO programming, which allows you to COMBINE data items of different kinds. Structure is another user defined data type available in Go programming, which allows you to combine data items of different kinds. |
|
| 14. |
What Is A Pointer On Pointer? |
|
Answer» 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 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 |
|
| 15. |
What Is A Nil Pointers In Go? |
|
Answer» 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. 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. |
|
| 16. |
What Is An Array? |
|
Answer» ARRAY is collection of SIMILAR data ITEMS under a COMMON name. Array is collection of similar data items under a common name. |
|
| 17. |
Which Key Word Is Used To Perform Unconditional Branching? |
|
Answer» goto goto |
|
| 18. |
What Is A Token? |
|
Answer» A Go program CONSISTS of VARIOUS TOKENS and a token is either a keyword, an identifier, a CONSTANT, a string literal, or a symbol. A Go program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol. |
|
| 19. |
Explain Modular Programming? |
|
Answer» 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. 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. |
|
| 20. |
What Is The Difference Between Variable Declaration And Variable Definition? |
|
Answer» DECLARATION associates TYPE to the variable WHEREAS definition gives the value to the variable. Declaration associates type to the variable whereas definition gives the value to the variable. |
|
| 21. |
What Is The Difference Between Actual And Formal Parameters? |
|
Answer» 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. 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. |
|
| 22. |
What Is Lvalue And Rvalue? |
|
Answer» 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. 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. |
|
| 23. |
Explain The Purpose Of The Function Printf()? |
|
Answer» Prints the formatted output. |
|
| 24. |
What Is Default Value Of A Pointer Variable In Go? |
|
Answer» POINTER is INITIALIZED to NIL. Pointer is initialized to nil. |
|
| 25. |
What Is Default Value Of A Global Variable In Go? |
|
Answer» A GLOBAL variable has DEFAULT VALUE as it corresponding 0 value. A global variable has default value as it corresponding 0 value. |
|
| 26. |
What Is Default Value Of A Local Variable In Go? |
|
Answer» A LOCAL VARIABLE has DEFAULT value as it corresponding 0 value. A local variable has default value as it corresponding 0 value. |
|
| 27. |
What Are Methods In Go? |
|
Answer» 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. 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. |
|
| 28. |
What Are The Function Closures? |
|
Answer» FUNCTIONS closure are ANONYMOUS functions and can be USED in DYNAMIC PROGRAMMING. Functions closure are anonymous functions and can be used in dynamic programming. |
|
| 29. |
What Do You Mean By Function As Value In Go? |
|
Answer» 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. 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. |
|
| 30. |
What Is The Default Way Of Passing Parameters To A Function? |
|
Answer» 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 while calling max() function used the same METHOD. 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 while calling max() function used the same method. |
|
| 31. |
In How Many Ways You Can Pass Parameters To A Method? |
|
Answer» While calling a function, there are two WAYS that arguments can be PASSED to a function:
While calling a function, there are two ways that arguments can be passed to a function: |
|
| 32. |
Can You Return Multiple Values From A Function? |
|
Answer» A GO function can return MULTIPLE VALUES. For example − package MAIN A Go function can return multiple values. For example − package main |
|
| 33. |
Explain The Syntax To Create A Function In Go? |
|
Answer» The general FORM of a function definition in Go programming language is as follows − func function_name( [parameter list] ) [return_types] A function definition in Go programming language consists of a function header and a function body. Here are all the parts of a function −
The general form of a function definition in Go programming language is as follows − func function_name( [parameter list] ) [return_types] A function definition in Go programming language consists of a function header and a function body. Here are all the parts of a function − |
|
| 34. |
Explain The Syntax For 'for' Loop? |
|
Answer» The syntax of a for loop in Go programming language is − for [CONDITION | ( init; condition; increment ) | RANGE] Here is the flow of control in a for loop −
The syntax of a for loop in Go programming language is − for [condition | ( init; condition; increment ) | Range] Here is the flow of control in a for loop − |
|
| 35. |
What Is The Purpose Of Goto Statement? |
|
Answer» GOTO TRANSFERS CONTROL to the LABELED STATEMENT. goto transfers control to the labeled statement. |
|
| 36. |
What Is The Purpose Of Continue Statement? |
|
Answer» Continue CAUSES the loop to skip the remainder of its BODY and IMMEDIATELY retest its CONDITION prior to reiterating. Continue causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating. |
|
| 37. |
What Is The Purpose Of Break Statement? |
|
Answer» Break TERMINATES the for loop or switch statement and TRANSFERS EXECUTION to the statement IMMEDIATELY following the for loop or switch. Break terminates the for loop or switch statement and transfers execution to the statement immediately following the for loop or switch. |
|
| 38. |
What Is A Pointer? |
|
Answer» It's a POINTER variable which can hold the address of a variable. For EXAMPLE − var x = 5 It's a pointer variable which can hold the address of a variable. For example − var x = 5 |
|
| 39. |
How To Print Type Of A Variable In Go? |
|
Answer» Following code PRINTS the type of a VARIABLE − var a, b, C = 3, 4, "FOO" Following code prints the type of a variable − var a, b, c = 3, 4, "foo" |
|
| 40. |
Can You Declared Multiple Types Of Variables In Single Declaration In Go? |
|
Answer» Yes Variables of DIFFERENT types can be declared in one go using type INFERENCE. Yes Variables of different types can be declared in one go using type inference. var a, b, c = 3, 4, "foo" |
|
| 41. |
What Is Dynamic Type Declaration Of A Variable In Go? |
|
Answer» A DYNAMIC type VARIABLE declaration requires compiler to interpret the type of variable based on value passed to it. Compiler don't NEED a variable to have type STATICALLY as a necessary requirement. A dynamic type variable declaration requires compiler to interpret the type of variable based on value passed to it. Compiler don't need a variable to have type statically as a necessary requirement. |
|
| 42. |
What Is Static Type Declaration Of A Variable In Go? |
|
Answer» Static type variable DECLARATION provides assurance to the compiler that there is one variable existing with the GIVEN type and name so that compiler proceed for further compilation WITHOUT needing complete detail about the variable. A variable declaration has its meaning at the time of compilation only, compiler NEEDS actual variable declaration at the time of LINKING of the program. Static type variable declaration provides assurance to the compiler that there is one variable existing with the given type and name so that compiler proceed for further compilation without needing complete detail about the variable. A variable declaration has its meaning at the time of compilation only, compiler needs actual variable declaration at the time of linking of the program. |
|
| 43. |
Is Go A Case Sensitive Language? |
|
Answer» Yes! Go is a CASE SENSITIVE programming LANGUAGE. Yes! Go is a case sensitive programming language. |
|
| 44. |
Does Go Support Generic Programming? |
|
Answer» No SUPPORT for GENERIC PROGRAMMING. No support for generic programming. |
|
| 45. |
Does Go Support Pointer Arithmetics? |
|
Answer» No SUPPORT for POINTER ARITHMETIC. No support for pointer arithmetic. |
|
| 46. |
Does Go Support Method Overloading? |
|
Answer» No SUPPORT for METHOD OVERLOADING. No support for method overloading. |
|
| 47. |
Does Go Support Operator Overloading? |
|
Answer» No SUPPORT for OPERATOR OVERLOADING. No support for operator overloading. |
|
| 48. |
Does Go Support Type Inheritance? |
|
Answer» No SUPPORT for TYPE INHERITANCE. No support for type inheritance. |
|
| 49. |
What Are The Benefits Of Using Go Programming? |
Answer»
|
|
| 50. |
What Is Go? |
|
Answer» Go is a general-purpose language designed with systems programming in mind.It was initially developed at Google in year 2007 by Robert Griesemer, Rob PIKE, and KEN Thompson. It is strongly and statically typed, provides INBUILT support for garbage collection and supports CONCURRENT programming. Programs are constructed using packages, for efficient management of dependencies. Go programming implementations use a traditional compile and link model to generate executable binaries. Go is a general-purpose language designed with systems programming in mind.It was initially developed at Google in year 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. It is strongly and statically typed, provides inbuilt support for garbage collection and supports concurrent programming. Programs are constructed using packages, for efficient management of dependencies. Go programming implementations use a traditional compile and link model to generate executable binaries. |
|