wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Go Quiz

Total questions: 15

Worksheet time: 15mins

Name
Class
Date
1.
What is the correct way to declare a variable in Go?
a)
var x int
b)
x := 10
c)
x int = 10
d)
x = 10
2.
How do you define a function in Go?
a)
func myFunc()
b)
def myFunc()
c)
function myFunc()
d)
myFunc => {}
3.
What is the purpose of the `recover` function in Go?
a)
To catch an error
b)
To prevent panic
c)
To resume execution after panic
d)
To stop execution
4.
What is the output type of a function that returns nothing?
a)
nil
b)
void
c)
none
d)
empty
5.
How do you define a constant in Go?
a)
const PI = 3.14
b)
define PI = 3.14
c)
let PI = 3.14
d)
PI := 3.14
6.
What happens if you use `panic()` in Go?
a)
Program continues
b)
Program terminates
c)
Function returns
d)
Nothing happens
7.
How do you handle an error in Go?
a)
if err != nil {}
b)
if err == nil {}
c)
try-catch
d)
handle(err)
8.
What keyword is used to import a package in Go?
a)
include
b)
import
c)
require
d)
use
9.
Which operator is used for short variable declaration in Go?
a)
=
b)
:=
c)
==
d)
::
10.
How do you create a new slice in Go?
a)
new([]int)
b)
make([]int)
c)
slice([]int)
d)
create([]int)
11.
What is the default value of an integer in Go?
a)
nil
b)
-1
c)
0
d)
undefined
12.
How do you define a struct in Go?
a)
type Person struct {}
b)
class Person {}
c)
define Person {}
d)
struct Person {}
13.
Which loop is available in Go?
a)
while
b)
for
c)
foreach
d)
repeat
14.
How do you concatenate two strings in Go?
a)
str1 + str2
b)
concat(str1, str2)
c)
str1 & str2
d)
str1 | str2
15.
What is the `defer` statement used for in Go?
a)
To call a function immediately
b)
To execute a function after the surrounding function returns
c)
To define a function
d)
To delay a function call