Assuming a package named pkg has a function named print, which starts with a lower case letter. Then when you import the pkg package in your program, you can call the function pkg.print.
Blog
Assume that variable s has been declared as a slice of integ…
Assume that variable s has been declared as a slice of integers. Which of the following is a Go statement that adds two integers 10 and 20 to the slice s?
Consider the following code fragment in Go that attempts to…
Consider the following code fragment in Go that attempts to define a function: func example(x int) (y int){ y = x+1 return } Which of the following is true about the given code?
Given the following Go code block: func test(n int, s string…
Given the following Go code block: func test(n int, s string) int { return n*len(s)} What is the type of the variable t on the left-hand of the following statement? t := test
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.
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”))}
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.
Given the following batch jobs Calculate the mean turnaroun…
Given the following batch jobs Calculate the mean turnaround time (MTT) using the Shortest Job First non-preemptive scheduling algorithm. Answer with a number. For example “3.45” or “3”. Priority 0 is the lowest priority.
For each of the following, select True or False: 1. Deadlock…
For each of the following, select True or False: 1. Deadlocks cannot occur with the flagging interest approach to busy waiting because each process indicates its interest in entering the critical region by setting a flag. [flag] 2. By combining the ideas of alternating turns and flagging interest, the Peterson Solution to busy waiting avoids deadlocks. [peterson] 3. When using a mutex, the process will block and yield the CPU if it cannot acquire the lock, rather than spinning. [mutex] 4. Mutual exclusion via message passing is limited to processes on the same machine. [message]
For each of the following statements regarding procedure cal…
For each of the following statements regarding procedure calls, mark true or false: 1. Parameters can be passed by name, using a variable’s name directly. [varName] 2. Procedure calls are named code. [nameCode] 3. A pointer to entry/return is typically found in a procedure call. [Pointer] 4. Procedure calls never contain local variables. [local]