W3Tutorials.net
Toggle Menu
Home
Online Go Compiler
Tutorials
Javascript Tutorials
Python Tutorials
Go Tutorials
Blog
All Posts
Go Language Fundamentals
Test your knowledge of Go syntax,variables,and control structures.
1. What is the file extension for Go source code files?
.go
.golang
.g
2. Which function serves as the entry point of a Go program?
init()
main()
start()
3. Which operator is used for short variable declaration in Go?
=
:=
var
4. What is the zero value for an uninitialized int variable in Go?
0
nil
undefined
5. How is a package imported in Go?
include "fmt"
import "fmt"
using "fmt"
6. What does the 'go' keyword do when preceding a function call?
Defines a new function
Starts a goroutine
Exits the program
7. Which built-in type represents an immutable sequence of bytes in Go?
bytearray
str
string
8. What is the result of 7 / 3 in Go (integer division)?
2
2.333
0
9. Which keyword declares a constant in Go?
const
constant
let
10. What is the purpose of the 'defer' statement?
Delays execution until the surrounding function exits
Defers error handling to the caller
Declares a variable for later use
11. Which of the following are basic (primitive) types in Go? (Select all that apply)
int
string
[]int (slice)
map[string]int
12. Which statements about Go interfaces are true? (Select all that apply)
Explicitly implemented with 'implements' keyword
Implicitly implemented by type methods
Contain method signatures only
Include variable declarations
13. Which are valid error handling practices in Go? (Select all that apply)
Return error as last return value
Using try/catch blocks
Checking errors with 'if err != nil'
Using panic and recover
14. What are features of Go's concurrency model? (Select all that apply)
Uses goroutines (lightweight threads)
Directly uses OS-level threads
Communicates via channels
Relies on shared memory by default
15. Go supports object-oriented programming with classes and inheritance.
True
False
16. Goroutines are managed by the Go runtime, not the operating system kernel.
True
False
17. A Go function can return multiple values.
True
False
18. What is the abbreviation for Go's official dependency management tool?
19. What keyword is used to exit a loop prematurely in Go?
20. Name the built-in function in Go that prints to standard output without appending a newline (not part of the fmt package).
Reset
Answered 0 of 0 — 0 correct