Chapter 2 - Advanced Principles Flashcards

1
Q

Difference of Object vs. value

A

value: abstract value, no lifecycle, no side effects, immutable (unveränderbar) state (integer, float, character), Object: describes a phenomenon in a problem domain, lifecycle (created, mutation, deletion), can e shared

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

define “type”

A

abstract description of properties of a set of objects

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

define “class”

A

implementation of a type

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

What are the pre- and postconditions of the Liskov substitution principle?

A

preconditions must not be widened by a subtype, postconditions must not be narrowed (verschmälert) by a subtype

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

explain subclass

A

T’ is a subclass of T if T’ is derived form T (Implementation inheritance)

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

explain subtype

A

T’ is a subtype of T if T-objects can be replaced by T’-objects (subtype is more strict than subclass)

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

what is covariance and contravariance?

A

Covariance: type of a method parameter is narrowed (eingeschränkt) in a subclass, Contravariance: type of a method parameter is widened (ausgeweitet) in a subclass. most oo-languages only support contravariance

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

What types are there for Inheritance?

A

Specialization: derived concrete subclass from concrete base class / Specification: concrete subclass implements abstract base class / Restriction: subclass restricts the base class interface / Combination: multiple inheritance / Construction: Implementation inheritance

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

How can you restrict the Inheritance Interface?

A

in order to prevent method overriding, you can use the keyword final

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

Explain Inheritance vs. Composition

A

inheritance: is-a relationship, composition is has-a relationship

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

What is the problem with Inheritance?

A

it violates encapsulation

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

how does a Java interface work?

A

it declares only abstract methods

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

how does a Java abstract class work?

A

it defines common and structural functional properties

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

Explain Factorization

A

Sachverhalt nur an einer einzigen Stelle festhalten, eliminates duplicate code

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

what is information hiding?

A

minimal coupling between classes, open-closed principle: class should be open for extensions but closed for modifications

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

What are Generic classes?

A

formal type parameters like “public class DoubleObject”

17
Q

What is PECS?

A

producer extends, consumer super

18
Q

What is Meta-Information?

A

information on properties of objects, classes and the inheritance hierarchy –> Java Reflection provides meta-information at runtime

19
Q

Explain Aspect-oriented Programming (AOP)

A

dividing a problem into aspects rather than objects/classes

20
Q

Explain the joint-point model (in AOP)

A

Joint point: point in a running program where behaviour can be added, advice: defines the behavior, point cut: quantify join points for executing advice

21
Q

What is Polymorphism and which types are there

A

multiple implementations of a method, types: parametric: generic classes or methods, inheritance: serveral implementations along the inheritance hierarchy, overloading: namespace extension, coercion: implicit type conversion