Search Header Logo

Backend Quiz 2 - variable declaration

Authored by Jamyang Choden

Computers

University

Used 4+ times

Backend Quiz 2 - variable declaration
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

9 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Is the following a valid way of initializing and assigning a value to a variable?
var bookTitle string = "Harry Potter"

Yes

No

Only sometimes

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Is the following a valid way of initializing an assigning a value to a variable?
fruitCount := 5

Yes

No

Only sometimes

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

After running the following code, Go will assume that the variable
quizQuestionCount
is of what type?
quizQuestionCount := 10

Float

Integer

String

Map

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Will the following code compile? Why or why not?
paperColor := "Green"
paperColor := "Blue"

Yes, because we are creating and assigning a value to the variable 'paperColor' twice.

No, because a variable can only be initialized one time. In this case, the ':=' operator is being used to initialize 'paperColor' two times

No, because ':=' is not a valid operator

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Are the two lines following ways of initializing the variable 'pi' equivalent?
pi := 3.14
var pi float64 = 3.14

Yes

No

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

This might require a bit of experimentation on your end :).  Remember that you can use the Go Playground at https://play.golang.org/ to quickly run a snippet of code.

Is the following code valid?

  1. package main

  2.  

  3. import "fmt"

  4.  

  5. deckSize := 20

  6.  

  7. func main() {

  8. fmt.Println(deckSize)

  9. }

Yes

No

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

We might be able to initialize a variable and then later assign a variable to it.  Is the following code valid?

package main

  1.  

  2. import "fmt"

  3.  

  4. func main() {

  5. var deckSize int

  6. deckSize = 52

  7. fmt.Println(deckSize)

  8. }

Yes

No

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers