Classes and Objects Flashcards
A class ___ and ___ are optional.
header; body

Classes can have a ___ ___ and one or more ___ ___’s.
primary constructor; secondary constructor

‘constructor’ can be omitted if the primary constructor doesn’t have any ___ or ___ ___.
annotations; visibility modifiers
In a class initialization code is placed inside ___ ___.
initializer blocks
A class can contain multiple ___ blocks.
initialization
You can use a ___ ___ when declaring class properties.
trailing comma
Secondary constructors are prefixed with the ___ keyword.
constructor
Each secondary constructor needs to ___ to the primary constructor (directly or indirectly).
delegate

Code in initializer blocks becomes part of the ___ ___.
primary constructor
Code in all ___ ___ and ___ ___ is executed before the secondary constructor body.
initializer blocks; property initializers
What are the 5 things classes can contain?
constructors and initializer blocks; functions; properties; nested and inner classes; object declarations
All classes have a common superclass ___.
Any
Mark a class with ___ to make it inheritable.
open
If the derived class has a primary constructor, the ___ ___ must be initialized there.
base class
If the derived class has no primary constructor, each ___ ___ has to initialize it using the ___ keyword.
secondary constructor; super
The explicit modifiers for overridable members are ___ and ___.
open; override
Members marked ___ is itself ‘open’.
override
To prohibit re-overriding, use ___.
final
Properties declared in a superclass that are then redeclared in a derived class must be prefaced with ___.
override
You can override a ‘val’ property with a ___ property, but not vice versa.
var
You can use override keyword as part of the ___ ___ in a primary constructor.
property declaration

Code in derived classes can call superclass functions using the ___ keyword.
super
Inside an inner class, accessing the superclass of the outer class is done with the ___ keyword qualified with the ___ ___ ___.
super; outer class name

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

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

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.
object

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