GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

Determine the output of each fmt.Println() statement in the…

Determine the output of each fmt.Println() statement in the following Go code block by selecting the correct answer at the end of the fmt.Println() statement.     s := []int{11, 12, 13, 14, 15, 16}   s = s[:0]   fmt.Println(“len=”, len(s), “cap=”, cap(s)) //output: [output2]    s = s[:5]   fmt.Println(“len=”, len(s), “cap=”, cap(s)) //output: [output3]    s = s[3:]   fmt.Println(“len=”, len(s), “cap=”, cap(s)) //output: [output4]

Read Details

All of the following is a difference between Go’s switch sta…

All of the following is a difference between Go’s switch statement and the switch statement in C/C++ and Java EXCEPT:

Read Details

Consider the following Go code block: var names = []string{“…

Consider the following Go code block: var names = []string{“Alex”, “Bob”, “Chris”}for _, s := range names{ fmt.Printf(“%s,”, s) /* note: no space after the comma in the format string */} Write the output of the code block above exactly as it appears on screen: [output]

Read Details

Which of the following statement declares two string variabl…

Which of the following statement declares two string variables named x and y and initializes them  to string literals “Hello” and “World” respectively?

Read Details

Consider the following main function in a Go program which c…

Consider the following main function in a Go program which crashes (panic) eventually: func main(){    fmt.Println(“Start”)   defer fmt.Println(“Deferred call”)   panic(“Crashed”)} The deferred call in the main function will still be executed when this program is run.

Read Details

Complete the following Go code block so that it declares gra…

Complete the following Go code block so that it declares grades as a map that maps student names to their grades and print out all student names and their grades (DON’T type unnecessary spaces in your answers):   grades := [maptype]{“Alex”: 93.2, “Bob”: 64.1, “Chris”: 70.5}   for [namegrade] := [range] grades {       fmt.Printf(“%s has a grade of %0.1f%%\n”, name, grade)    } Expected output: Alex has a grade of 93.2% Bob has a grade of 64.1% Chris has a grade of 70.5%

Read Details

Given the following declaration: var s string = “GoLang” Mat…

Given the following declaration: var s string = “GoLang” Match each fmt.Println() statement with its output. Recall that the ASCII code of character ‘G’ is 71, and the ASCII code of character ‘o’ is 111.

Read Details

Define a Go’s struct type named BinaryTree that represents a…

Define a Go’s struct type named BinaryTree that represents a binary tree. This struct must have three fields: one field of type int that represents the value at the root of the tree,  one field is a pointer pointing to the left subtree which is also of type BinaryTree one field is a pointer pointing to the right subtree which is also of type BinaryTree

Read Details

The following Go code block will cause a panic: func main(){…

The following Go code block will cause a panic: func main(){  var f func(string) int  fmt.Println(f(“test”))} 

Read Details

What is the output of the following Go code block, assuming…

What is the output of the following Go code block, assuming it is in the program that imports the fmt package: var x int = 20if  x := 10;  x < 11 {   fmt.Println("Value of x inside the if statement:", x)}fmt.Println("Value of x outside the if statement:", x)

Read Details

Posts pagination

Newer posts 1 … 37,376 37,377 37,378 37,379 37,380 … 96,531 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top