- Go Tutorial
- Go - Home
- Go - Overview
- Go - Environment Setup
- Go - Program Structure
- Go - Basic Syntax
- Go - Data Types
- Go - Variables
- Go - Constants
- Go - Operators
- Go - Decision Making
- Go - Loops
- Go - Functions
- Go - Scope Rules
- Go - Strings
- Go - Arrays
- Go - Pointers
- Go - Structures
- Go - Slice
- Go - Range
- Go - Maps
- Go - Recursion
- Go - Type Casting
- Go - Interfaces
- Go - Error Handling
- Go Useful Resources
- Go - Questions and Answers
- Go - Quick Guide
- Go - Useful Resources
- Go - Discussion
Go Mock Test
This section presents you various set of Mock Tests related to Go. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
Go Mock Test III
Q 1 - Which of the following is correct about slices in Go?
A - Go Slice uses array as an underlying structure.
B - len() function returns the elements presents in the slice.
C - cap() function returns the capacity of slice as how many elements it can be accomodate.
Answer : D
Explanation
All of the above options are correct.
Q 2 - Which of the following function returns the total number of elements present in a slice?
Answer : B
Explanation
len() function returns the elements presents in the slice.
Q 3 - Which of the following function returns the capacity of slice as how many elements it can be accomodate?
Answer : C
Explanation
cap() function returns the capacity of slice as how many elements it can be accomodate.
Q 4 - Which of the following is correct about slices in Go?
A - If a slice is declared with no inputs the by default, it is initialized as nil.
B - length of a nil slice is 0.
Answer : D
Explanation
All of the above options are correct.
Q 5 - Which of the following function can be used to increase the capacity of a slice in Go?
Answer : A
Explanation
Slice allows increasing the capacity of a slice using append() function.
Q 6 - Which of the following function can be used to copy a slice to another slice in Go?
Answer : B
Explanation
Using copy() function, contents of a source slice are copied to destination slice.
Q 7 - Which of the following is correct about ranges in Go?
A - The range keyword is used in for loop to iterate over items of an array, slice, channel or map.
B - With array and slices, it returns the index of the item as integer.
C - With maps, it returns the key of the next key-value pair.
Answer : D
Explanation
All of the above options are correct.
Q 8 - Which of the following is correct about maps in Go?
A - Go provides another important data type map which maps unique keys to values.
B - A key is an object that you use to retrieve a value at a later date.
Answer : C
Explanation
Both of the above options are correct.
Q 9 - Which of the following is correct about maps in Go?
A - Given a key and a value, you can strore the value in a Map object.
B - After value is stored, you can retrieve it by using its key.
Answer : C
Explanation
Both of the above options are correct.
Q 10 - Which of the following is correct about maps in Go?
A - delete() function is used to delete an entry from the map.
B - delete() function requires map and corresponding key which is to be deleted.
Answer : C
Explanation
Both of the above options are correct.
Q 11 - Which of the following is correct about type casting in Go?
A - Type casting is a way to convert a variable from one data type to another data type.
B - if you want to store a long value into a simple integer then you can type cast long to int.
Answer : C
Explanation
Both of the above options are correct.
Q 12 - Which of the following is correct about interfaces in Go?
Answer : C
Explanation
Both of the above options are correct.
Q 13 - Which of the following terminates the for loop or switch statement and transfers execution to the statement immediately following the for loop or switch in Go?
Answer : A
Explanation
break terminates the for loop or switch statement and transfers execution to the statement immediately following the for loop or switch.
Q 14 - Which of the following causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating in Go?
Answer : B
Explanation
continue causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.
Q 15 - Which of the following transfers control to the labeled statement in Go?
Answer : C
Explanation
goto transfers control to the labeled statement.
Q 16 - Which of the following is true about for loop in Go if for clause that is ( init; condition; increment ) is present?
A - The init step is executed first, and only once.
B - init step allows you to declare and initialize any loop control variables.
C - You are not required to put a statement in init step, as long as a semicolon appears.
Answer : D
Explanation
All of the above options are correct.
Q 17 - Which of the following is true about for loop in Go if for clause that is ( init; condition; increment ) is present?
A - After init step, the condition is evaluated.
Answer : D
Explanation
All of the above options are correct.
Q 18 - Which of the following is true about for loop in Go if for clause that is ( init; condition; increment ) is present?
Answer : D
Explanation
All of the above options are correct.
Q 19 - Which of the following method of parameter passing, copies the actual value of an argument into the formal parameter of the function?
Answer : A
Explanation
Call by value − This method copies the actual value of an argument into the formal parameter of the function.
Q 20 - In which of the following method of parameter passing, changes made to the parameter inside the function have no effect on the argument?
Answer : A
Explanation
Call by value − changes made to the parameter inside the function have no effect on the argument.
Q 21 - Which of the following method of parameter passing, copies the address of an argument into the formal parameter?
Answer : B
Explanation
Call by reference − This method copies the address of an argument into the formal parameter.
Q 22 - In which of the following method of parameter passing, changes made to the parameter inside the function have effect on the argument?
Answer : B
Explanation
Call by reference − changes made to the parameter inside the function have effect on the argument.
Q 23 - Which of the following method is the default method of parameter passing in Go?
Answer : A
Explanation
By default, Go uses call by value to pass arguments.
Q 24 - Go programming language is strongly and statically typed, provides inbuilt support for garbage collection?
Answer : A
Explanation
Go programming language is strongly and statically typed, provides inbuilt support for garbage collection.
Q 25 - In Go programming language, Programs are constructed using packages, for efficient management of dependencies?
Answer : B
Explanation
Programs are constructed using packages, for efficient management of dependencies.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | D |
2 | B |
3 | C |
4 | D |
5 | A |
6 | B |
7 | D |
8 | C |
9 | C |
10 | C |
11 | C |
12 | C |
13 | A |
14 | B |
15 | C |
16 | D |
17 | D |
18 | D |
19 | A |
20 | A |
21 | B |
22 | B |
23 | A |
24 | A |
25 | B |