Go Aptitude Test
This Go Aptitude Test provides 25 multiple-choice questions for beginners to test Go (Golang) programming basic concepts and syntax.
This Go Aptitude Test provides 25 multiple-choice questions for beginners to test Go (Golang) programming basic concepts and syntax.
1. How are errors represented in Go? a) As a separate error type b) Using the Exception struct c) With integer codes d) As boolean flags Click to View Answer and Explanation Answer: a) As a separate error type Explanation: In Go, errors are represented as a built-in interface type, 'error', which is a conventional
1. Which package is primarily used for date and time in Go? a) time b) date c) datetime d) timestamp Click to View Answer and Explanation Answer: a) time Explanation: The 'time' package in Go provides functionality for measuring and displaying time. 2. How do you get the current time in Go? a) time.Now() b)
Go Date and Time MCQ Read More »
1. Which keyword is used to create a new goroutine in Go? a) go b) goroutine c) async d) thread Click to View Answer and Explanation Answer: a) go Explanation: The 'go' keyword is used in Go to launch a new goroutine, which is a lightweight thread managed by the Go runtime. 2. What is
Go Concurrency MCQ Read More »
1. Which keyword is used for conditional execution in Go? a) if b) switch c) case d) check Click to View Answer and Explanation Answer: a) if Explanation: The 'if' keyword is used for conditional execution in Go, allowing the program to execute certain code only if a specified condition is true. 2. What is
Go Control structures MCQ Read More »
1. How do you define a struct in Go? a) struct MyStruct {} b) type MyStruct struct {} c) define MyStruct struct d) MyStruct := struct {} Click to View Answer and Explanation Answer: b) type MyStruct struct {} Explanation: In Go, a struct is defined using the 'type' keyword followed by the struct name
1. What is the basic loop construct in Go? a) for b) while c) do-while d) loop Click to View Answer and Explanation Answer: a) for Explanation: Go uses the 'for' keyword as its basic and only loop construct. 2. How do you create an infinite loop in Go? a) for {} b) for true
1. How do you declare a slice in Go? a) var mySlice []int b) mySlice := []int{} c) []int mySlice d) Both a and b Click to View Answer and Explanation Answer: d) Both a and b Explanation: A slice in Go can be declared either with 'var mySlice []int' for a nil slice, or
1. How do you declare an array of 10 integers in Go? a) var arr [10]int b) var arr int[10] c) int arr[10] d) array arr[10]int Click to View Answer and Explanation Answer: a) var arr [10]int Explanation: In Go, arrays are declared by specifying the type of the elements and the number of elements
1. What is the default type of an integer literal in Go if it does not fit into int32? a) int32 b) int64 c) int d) uint64 Click to View Answer and Explanation Answer: b) int64 Explanation: If an integer literal exceeds the size of int32, Go defaults to int64 for the literal's type. 2.
1. How do you declare a constant in Go? a) const myConst = 10 b) var myConst = 10 c) myConst := 10 d) #define myConst 10 Click to View Answer and Explanation Answer: a) const myConst = 10 Explanation: Constants in Go are declared using the 'const' keyword followed by the constant name and
1. What is the correct syntax for declaring a variable in Go? a) var myVar int b) int myVar c) myVar := int d) declare myVar as int Click to View Answer and Explanation Answer: a) var myVar int Explanation: In Go, a variable is declared using the 'var' keyword followed by the variable name