Classes and Objects Flashcards

1
Q

A class ___ and ___ are optional.

A

header; body

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

Classes can have a ___ ___ and one or more ___ ___’s.

A

primary constructor; secondary constructor

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

‘constructor’ can be omitted if the primary constructor doesn’t have any ___ or ___ ___.

A

annotations; visibility modifiers

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

In a class initialization code is placed inside ___ ___.

A

initializer blocks

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

A class can contain multiple ___ blocks.

A

initialization

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

You can use a ___ ___ when declaring class properties.

A

trailing comma

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

Secondary constructors are prefixed with the ___ keyword.

A

constructor

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

Each secondary constructor needs to ___ to the primary constructor (directly or indirectly).

A

delegate

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

Code in initializer blocks becomes part of the ___ ___.

A

primary constructor

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

Code in all ___ ___ and ___ ___ is executed before the secondary constructor body.

A

initializer blocks; property initializers

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

What are the 5 things classes can contain?

A

constructors and initializer blocks; functions; properties; nested and inner classes; object declarations

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

All classes have a common superclass ___.

A

Any

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

Mark a class with ___ to make it inheritable.

A

open

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

If the derived class has a primary constructor, the ___ ___ must be initialized there.

A

base class

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

If the derived class has no primary constructor, each ___ ___ has to initialize it using the ___ keyword.

A

secondary constructor; super

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

The explicit modifiers for overridable members are ___ and ___.

A

open; override

17
Q

Members marked ___ is itself ‘open’.

A

override

18
Q

To prohibit re-overriding, use ___.

A

final

19
Q

Properties declared in a superclass that are then redeclared in a derived class must be prefaced with ___.

A

override

20
Q

You can override a ‘val’ property with a ___ property, but not vice versa.

A

var

21
Q

You can use override keyword as part of the ___ ___ in a primary constructor.

A

property declaration

22
Q

Code in derived classes can call superclass functions using the ___ keyword.

A

super

23
Q

Inside an inner class, accessing the superclass of the outer class is done with the ___ keyword qualified with the ___ ___ ___.

A

super; outer class name

24
Q

To denote the supertype from which an inherited implementation is taken, we use ___ qualified by the ___ ___ in angle brackets.

A

super; supertype name

25
Q

True or false: We can override a non-abstract open member with an abstract one.

A

true

26
Q

If you need to write a function that can be called without having a class instance but needs access to the internals of a class, you can write it as a member of an ___ declaration.

A

object

27
Q

If you declare a ___ ___ inside your class, you can access its members using only the class name as a qualifier.

A

companion object