Go Programming

Go Errors MCQ

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

Go Errors MCQ Read More »

Go Date and Time MCQ

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 »

Go Concurrency MCQ

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 »

Go Struct MCQ

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

Go Struct MCQ Read More »

Go Loops MCQ

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

Go Loops MCQ Read More »

Go Slices MCQ

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

Go Slices MCQ Read More »

Go Arrays MCQ

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

Go Arrays MCQ Read More »

Go Data Types MCQ

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.

Go Data Types MCQ Read More »

Go Constants MCQ

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

Go Constants MCQ Read More »

Go Variables MCQ

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

Go Variables MCQ Read More »

Scroll to Top