Which of the following is a correct example of embedding a struct within another struct in Go?
What is the output of the following Go code?
package main
import "fmt"
func main() {
var ptr *int
var num int = 10
ptr = &num
*ptr = 20
fmt.Printf("%d\n", num)
}
What is defer in Go?
What is a method set in Go?
What is composition in Go?
What is abstraction in Go?
Which of the following is true about encapsulation in Go?
What is polymorphism in Go?
What is the output of the following Go code snippet if an error occurs while opening the file?
file, err := os.Open("file.txt")
defer file.Close()
if err != nil {
fmt.Println("Error:", err)
} else {
fmt.Println("File opened successfully.")
}
What is the difference between a value receiver and a pointer receiver in Go?