Strings, Runes and Bytes Quiz
Which byte slice below equals to the "keeper" string?
- []byte{107, 101, 101, 112, 101, 114} CORRECT
- []byte{112, 101, 101, 112, 114, 101}
- []byte{114, 101, 112, 101, 101, 112}
- []byte{112, 101, 101, 114, 107, 101}
What does this code print?
- 103 111
- g o CORRECT
- n o
- "103 111"
What does this code print?
- 7 10 2 CORRECT
- 10 7 1
- 10 7 2
- 7 7 1
Which one below is true?
- for range loops over the bytes of a string
- for range loops over the runes of a string CORRECT
For a utf-8 encoded string value, which one below is true?
- runes always start and end in the same indexes
- runes may start and end in different indexes CORRECT
- bytes may start and end in different indexes
Why can't you change the bytes of a string value?
- Strings values are immutable byte slices
- Strings are used a lot so they are being shared behind the scenes
- All of above CORRECT