INFO5126 Quiz #1 Flashcards

(31 cards)

1
Q

Who developed Kotlin?

A

JetBrains

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does Kotlin compile to native code?

A

LLVM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the 5 reasons to use Kotlin? (Can’t Sell In The Nude)

A
  1. Concise
  2. Safe
  3. Interoperable
  4. Tool Friendly
  5. No checked exceptions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why is Kotlin considered safe?

A

Avoids entire classes of errors like Null Pointer Exception

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which keyword is used for read only variables?

A

val

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which keyword is used for mutable variables?

A

var

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you perform string interpolation?

A

$ and { }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you test that two variables refer to the same object?

A

===

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What keyword is used for switch statements?

A

when

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the Elvis operator?

A

?:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What operator is used to return the non-null type value and throw an exception if the value is null?

A

!!
val l = b!!.length

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What operator returns the expression on the left if not null and the expression on the right if null?

A

?:
val l = b?.length ?: 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you filter out non-null elements from a collection of Nullable type?

A

filterNotNull()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What function instantiates an immutable list?

A

listOf()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What function instantiates a mutable list?

A

mutableListOf()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What keyword is used to declare a function?

17
Q

Class member functions are ________

18
Q

Class members are ________ by default

19
Q

Classes are ________ by default

20
Q

If a class member is not initialized during construction what keyword do you use to initialize it?

21
Q

What keyword is used to create a Singleton?

22
Q

What keyword is used for static methods?

23
Q

What is view binding a subset of?

24
Q

In most cases view binding replaces what function?

A

findViewById()

25
What file do you change to enable view binding?
Gradle Module
26
What function is used with view binding to give direct reference to the root view of the corresponding layout file?
getRoot()
27
What does ViewBinding change the IDs of the XML layout file to?
camelCase
28
What library did we use for JSON with Kotlin?
GSON
29
What kind of class should you use when working with JSON?
data
30
What keyword should you use to make data class field names different from the JSON names?
@SerializedName("key_name")
31
How do you parse a class object into JSON using GSON?
Gson().toJson(Object)