Exam 3 Flashcards

1
Q

encapsulation

A

group data and operations in one place

hide irrelevant deails (using visibility modifiers)

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

Subtyping

A

define functions for that type

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

static dispatch

A

dispatch to the parent class
easier to implement and more efficient
compiler can always tell which implementation at compile time

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

dynamic dispatch

A

dispatch to the implementation based on the actual object

less efficient but provides better extensibility

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

virtual table

A

shared table containing method binaries,

one per class

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

Upcasting is always safe

A

Down casting not safe

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

Operation classifications

A

creators, producers, mutators, observers

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

Contract

A

precondition - assumptions on inputs
side effects - changes to the value
post condition - functionality of the operation
invariants - a property that is always true throughout the operation

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

Why contract

A

separation of concerns:
preconditions/input values - user’s responsibility
side effects - users should be awawar of
postconditions/output values - ADT’s responsibility

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

Loop invariant

A
Initially true: 
P-> Inv
true after each iter:
Inv ^E -> wp (s, Iv)
termination of loop -> post cond
Inv ^notE ->Q
How well did you know this?
1
Not at all
2
3
4
5
Perfectly