Which keyword is used in Go to implement interfaces?
What is the output of the following code?
package main
import "fmt"
func main() {
a := make([]int, 3, 6)
fmt.Println(len(a))
}
What is the output of the following code?
package main
import "fmt"
func main() {
a := []int{1, 2, 3}
b := []int{4, 5, 6}
a = append(a, b...)
fmt.Println(a)
}
What is the output of the following code?
package main
import "fmt"
func main() {
a := []int{1, 2, 3}
b := []int{4, 5, 6}
copy(a, b)
fmt.Println(a, b)
}
What is the output of the following code?
go
Copy code
package main
import "fmt"
type myInt int
func (mi myInt) double() {
mi *= 2
}
func main() {
mi := myInt(2)
mi.double()
fmt.Println(mi)
}
What is an anonymous field in Go?
Which of the following is true about Go's interfaces?
What is a pointer receiver in Go?
Define a struct called "Rectangle" with properties "length" and "width". Create a method called "area" that returns the area of the rectangle. Implement this method using pointer receivers.
Define a struct called "Person" with properties "name" and "age". Create a method called "greet" that takes no arguments and returns a string. The string should say "Hello, my name is [name] and I am [age] years old." Implement this method using value receivers.