Go course

Projects and Final ReviewFinal Quiz: Reviewing Every Chapter

Go

Display

Theme

Projects and Final Review · Quiz

Final Quiz: Reviewing Every Chapter

This closing quiz covers material from the whole course: variables, functions, structs, interfaces, errors, slices, maps, pointers, channels, mutexes, generics, and enums. If you miss an answer, go back to the relevant chapter and reread that section.

Congratulations on finishing the Go course!

  1. Question 1 of 6What does this program print?
    s := []int{1, 2, 3}
    t := s[:2]
    t[0] = 99
    fmt.Println(s[0], len(t), cap(t))
  2. Question 2 of 6What happens when this code runs?
    var stok map[string]int
    stok["kopi"] = 10
  3. Question 3 of 6Why doesn't this function change the caller's balance?
    type Akun struct{ Saldo int }
    
    func tambah(a Akun, n int) {
    	a.Saldo += n
    }
  4. Question 4 of 6Given err := fmt.Errorf("simpan pesanan: %w", ErrStokHabis). Which expression is true?
  5. Question 5 of 6What happens with this program?
    func main() {
    	ch := make(chan int)
    	ch <- 1
    	fmt.Println(<-ch)
    }
  6. Question 6 of 6A Sensor type has the method func (s *Sensor) Baca() float64. Which of these satisfies the interface Pembaca { Baca() float64 }?