Go Lang/ Go Lang mcq Sample Test,Sample questions

Question:
 What is the output of below code snippet?
package main

import (
        "fmt"
)

func main() {
        x := [2]int{1,2}
        r := [...]int{1,2}
        fmt.Println(x==r)
}

1.False

2.Compile time Error

3.Run time Error

4.True

Posted Date:-2022-09-17 16:41:44


Question:
 What is the output of below code snippet?package mainimport (        "fmt")func main() {        x := [...]string{1:"xyz", 2:"pqr"}        fmt.Println(x[0],x[1])}

1.Space xyz

2.only xyz

3.xyz pqr

4.None of the above

Posted Date:-2022-09-17 16:45:30


Question:
what is the output of below code snippet
package main

import "fmt"

func main() {
	fmt.Println("Hello " + "World")
}

1..Hello

2.Hello World

3.Compile error

4.None of the above

Posted Date:-2022-09-17 16:48:35


Question:
what is the output of below code snippet
package main

import (
        "fmt"
)

func main() {
        var x int
        lstArray := [3]int{1, 2, 3}
        x, lstArray = lstArray[0], lstArray[1:]
        fmt.Println( x, lstArray)
}

1.1 [2,3]

2. 1 [1,2,3]

3.Error

4.None of the above

Posted Date:-2022-09-17 16:28:40


Question:
what is the output of below code snippet
package main

import (
        "fmt"
)

func main() {
        var x int
        lstArray := []int{1, 2, 3}
        x, lstArray = lstArray[0], lstArray[1:]
        fmt.Println( x, lstArray)
}

1. [1,2,3]

2.. 1 [2,3]

3.Error

4.None of the above

Posted Date:-2022-09-17 16:30:21


Question:
What is the output of below code snippet?
package main

import (
        "fmt"
)

func ElementChange(x [3]int) {
        x[2] = 5
}

func main() {
        x := [3]int{1, 2}
        ElementChange(x)
        fmt.Println(x)
}

1..[1 2 5]

2.[1 2]

3. [1 2 0]

4.None of the above

Posted Date:-2022-09-17 16:44:30


Question:
what is the output of below code snippet?
package main

import (
        "fmt"
)

func main() {
        var x int
        lstArray := [...]int{1, 2, 3}
        x, lstArray = lstArray[0], lstArray[1:]
        fmt.Println(x, lstArray)
}

1.1 [1 2 3]

2. 1 [2 3]

3.Error

4.None of the above

Posted Date:-2022-09-17 16:40:21


More MCQS

  1. Go Lang mcq
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!