Advanced Mechanisms & Techniques Flashcards

1
Q

Mutable Object?

A

Object that can be changed, ex. getters and setters of objects

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

Immutable object?

A

Can’t be changed after creation. Make it immutable by making all fields final and private. for example primitive types

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

Refactoring?

A

Improving the code. For example, cleaner, simpler, better adhere to principles!

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

Threads?

A

Multiple activities at once are called Threads. Each activity is an instance of the “Thread-class”.

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

Thread Safety?

A

-Means that multiple threads can be excecuted simultaneously without any undesirable behaviors.

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

Defensive copying?

A

A identical, but disconnected, copy of an object is returned instead of the original one. Any modification of the returned object will not affect the original one. Reduces chance of bugs since objects, at creation, can be immutable

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

Exceptions?

A

Exceptions disrupts the flow of the program, and this terminates abnormally. Exceptions are caught by using “Catch”. There are checked and unchecked exceptions, what ever they are :P

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

Immutable Adapter?

A

An object that cannot easily be copied, one can apply an adapter to make it appear as if it were immutable. Achieved by making an dapater-class which delegates the methods that do not mutate the object from the mutable object

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

Mutate-By-Copy?

A

Instead of changing an object’s properties, create a copy of the object with the new properties, and return that instead. The original object cannot be changed by alias updates. Applicable when one wishes to change the properties of the object for a single instance, but not for all instances of said object.

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

Polymorphism?

A

“An object of a type can be used as if it is of a different type”

Allows an object, a method to behave as if it had several different types, i.e. its ability of an object to take on many forms. Any object that IS-A subtype of an object type is considered to be polymorphic

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

Subtype polymorphism?

A

If S is a subtype of T, then any object of type S can behave like an object of type T:

  • For every subtype, “O” has a form( Scania is a Truck which is a Vehicle). Thus Scania has the behavior of a Truck and a Vehicle.
  • A variable X with a static (declared) type T can at runtime point to an object with dynamic type “S” I.e. it can use any methods defined in T(or any superclass that T inherits from)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Parametric Polymorphism?

A

Creates a method or a class with generic code that works for whichever type the parameter is.

The code is independent of the objects type, and thus applicable to multiple different types

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

Delegation?

A

When a class (B) contains an instance of another class (C) in order to make use of C’s methods

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

Inheritance?

A

When one class gains the properties of another superclass. Attributes or methods do not all be defined in one class but can be gained from another class

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

Type Constructor?

A

A type constructor is a syntax around creating a collection of a specific type
The specified type of the collection is the type argument

Pair < T >, ”T” is the type parameter. Pair < String >, ”String” is the type argument and ”Pair” type constructor

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

Type parameters?

A

A placeholder for a type declared, it specified which types can be inputted into a method - it has several bounds

17
Q

Type Arguments?

A

Is the actual type that is inputted into a method. While type parameters define what types are allowed to be inputted