Help for the VSCode editor.
-
A constant is initialised using the keyword:
var
fixed_var
const
constant
Reveal
const
-
Select the valid statements for declaring and initialising a constant
const c int = "mouse"
const c int = 90
const c = 90
const c int = 90.00
Reveal
B, C
A and D are type mismatches.
-
Select the correct statements
-
const c int = 70
-
const c int c = 70
-
var c int c = 70
-
var c = 90
Reveal
A, C, D
B is incorrect becaose a
const
must be assigned a value when it is declared, not in a separate statement. -
-
Can you use shorthand declaration for declaring constants (:=)
- No
- Yes
- Optional
- None of the above
Reveal
No
-
Which of the following statement will throw an error
-
const name = "Harry" fmt.Print(name)
-
var name = "Harry" fmt.Print(name)
-
const name = "Harry" name = "Snape" fmt.Print(name)
-
var name string = "Harry" fmt.Print(name)
Reveal
C
const
is by definition constant. This means that once declared, it cannot be reassigned. -