Unit 1: Aplikasi Android pertama Anda
Pengantar Kotlin
1.
Which of the following
variable declarations is valid?
var hello: Int? = ""
val hello = "hello"
hello: String = "hello"
2.
It is considered
best practice to declare a variable that will not change using var instead of val.
False
Correct!
3.
Which of the
following are valid ways to update a variable?
Choose as many answers as you see fit.
Partially
Correct.
total++
Correct!
total - 1
total--
total = total + 1
Correct!
4.
In Kotlin,
comments can be single or multi-line and are ignored by the compiler.
True
False
5.
Which of the
following is not a data type in Kotlin?
Decimal
Correct!
6.
Float also represents a decimal, but is less precise
than Double.
True
Correct!
7.
In Kotlin, the
entrypoint of a program is the ___.
main() function
Correct!
8.
Which of the following
are true about function return values?
Choose as many answers as you see fit.
Partially
Correct.
If
a function does not specify a return type, the return type is Unit.
Correct!
A
return value can be stored in a variable.
A
return value's type must match the return type of a function.
Correct!
9.
Which of the
following are true about functions?
Choose as many answers as you see fit.
Partially
Correct.
Functions
can take parameters, or variables as inputs.
Correct!
When
calling a function with parameters, the values passed in are called arguments.
Correct!
Breaking
up your code into separate functions makes your code easier to maintain.
Correct!
10.
With named
arguments, you can change the order in which you pass arguments into a
function.
True
Correct!
Tidak ada komentar:
Posting Komentar