What is printed when the following program is executed?

Module 3 Quiz >>> What is printed when the following program is executed >>> Getting Started with Go

 

That’s correct! The program scans the slice x and assigns y to the largest value in x. The largest value is 8.

==============================

That’s correct! Variables y and z are both slices over different regions of the array x. Variable y[0] refers to the first element of x, and variable z[1] refers to the third element of z. The result of the assignments is to change the first and third elements of x to 1 and 3, respectively.

==============================

That’s correct! The program first creates a slice s with length 0 and capacity 3. Then the program appends an element to the slice which increases its length to 1, but does not change its capacity since the adding the element did not require the capacity to increase.

==============================

==============================

==============================

That’s correct! The program makes a map containing two key,value pairs: (“ian”, 1) and (“harris”, 2). The loop searches for the key “harris” and prints the key “harris” together with its value 2.

 

 

Leave a Comment