Midterm Review Flashcards

1
Q

What is the Android Manifest File?

A

The file which provides the OS with important information about the app including components, permissions, minimum API level, and other configurations

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

What is Val and Var?

A

Val - readonly/assign once
Var - mutable, can be changed/reassigned

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

How do you initialize and specify the type of a variable on the same line?

A

val characters: CharSequence = “abc”

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

How do you do string interpolation?

A

Using $ and { }

val name = “Anne”
val yearOfBirth = 1985
val yearNow = 2018
val message = “$name is ${yearNow - yearOfBirth} years old“

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

?

A

Null safety, used to set variables as nullable

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

!!

A

Returns non-null type value and throws exception if the value is null

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

?:

A

Elvis operator. Returns the expression to the left if not null, right if null

val l = b?.length ?: -1

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

Safe casting

A

val aInt: Int? = a as? Int

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

Null Filtering

A

Nullable collections can use filterNotNull() to filter out non-null elements

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

What is the When Statement?

A

Switch in Kotlin.

when (op) {
	"add" -> return a + b
	"subtract" -> return a - b
	"multiply" -> return a * b
	"divide" - > return a / b
	else -> throw Exception()
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are companion objects?

A

An object declaration inside a class which allows you to define members that belong to the class itself rather than the instance, often used to hold static-like methods and properties that are accessible without creating an instance of the class (accessed via class name)

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

What is Lazy?

A

A property delegate that allows you to initialize a property only on access rather than time of object creation (lazy initialization)

val propertyName: Type by lazy { initializer }

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

What is a Data Class?

A

A special type of class primarily designed to hold data which automatically provides a set of standard functionalities

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

What are the Features of a Data Class?

A

Equals(), hashCode(), toString(), copy(), componentN()

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

What are Inner Classes?

A

Classes defined within another class using “inner” which have access to the instance of the outer class

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