Backend Quiz 2 - variable declaration

Backend Quiz 2 - variable declaration

University

9 Qs

quiz-placeholder

Similar activities

Kuis PBO-1

Kuis PBO-1

University

10 Qs

Java 6

Java 6

University

10 Qs

JAVA Array (1)

JAVA Array (1)

University

10 Qs

1D Array

1D Array

University

10 Qs

BCSC0006 - Quiz 1 - Arrays

BCSC0006 - Quiz 1 - Arrays

University

10 Qs

Introduction to Arrays

Introduction to Arrays

KG - University

10 Qs

Java Programming Basics

Java Programming Basics

University

10 Qs

DEBUG THE CODE

DEBUG THE CODE

University

10 Qs

Backend Quiz 2 - variable declaration

Backend Quiz 2 - variable declaration

Assessment

Quiz

Computers

University

Medium

Created by

Jamyang Choden

Used 4+ times

FREE Resource

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

8.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Here's another one that might need some testing 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. var deckSize int

  6.  

  7. func main() {

  8. deckSize = 50

  9. fmt.Println(deckSize)

  10. }

Yes

No

9.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Is the following code valid?  Why or why not?

  1. package main

  2.  

  3. import "fmt"

  4.  

  5. func main() {

  6. deckSize = 52

  7. fmt.Println(deckSize)

  8. }

Yes, because deckSize is assigned a value before it is passed to the 'fmt.Println' function

No, because 'deckSize' is assigned a value before it is initialized