Database Abstraction and OOP Flashcards

1
Q

What are some benefits of abstractions?

A
  • Easier to think about
  • Prevent access to things you shouldn’t see
  • plug compatibility (replacement of pieces often without recompilation)
  • Division of laber in software projects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the three key factors in OOP?

A
  • Encapsulation (data hiding)
  • Inheritance
  • Dynamic method binding
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Can you tell at compilation time what will be printed on the last line of the code below?

A

No. It depends if runtime uses static or dynamic binding.

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

Can x access field b?

x.b

A

No. Only the child (subclass) knows that the record goes farther the parent does.

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

What are dynamically bound methods called in C++?

A

Virtual

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

In C++, how are default methods bounded?

A

Statically

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

In Java, how are default methods bounded?

A

Dynamically (virtual)

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

(T/F) Non-virtual functions (static) require no space at run time. Explain.

A

True

The compiler just calls the appropriate version, based on the static type of the variable.

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

(T/F) Virtual functions are passed an extra, hidden, paramter.

A

True

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

Virtual functions in C++ have a dispatch table (vtable) for the class.

(T/F) Subclasses create their own vtables.

A

True

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

What happens if the order of the vtable methods get reordered?

A

All clients will have to recompile.

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

In Java, reordering the vtable and loosing linkage is resolved how?

A

Java uses symbolic links which are resolved after compile time to find the offset into the method table.

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

Give an example of repeated inheritance.

A
  • Shared inheritance
  • Replicated inheritance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a mix-in inheritance?

A

Single inheritance from on “real” base class, plus multiple inheritance from abstract classes (interfaces in Java).

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

Does a constructor allocate space?

A

No. It initializes the object.

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

(T/F) In C++, when an object of a derived class is created, the constructors for any base class will be executed before the constructor for the derived class.

A

True

17
Q

(T/F) In C++ finalization, destructors for superclasses are called first followed by the destructor for the subclass.

A

False

18
Q

Genericity VS Inheritance

Describe Genericity.

A

Parametric polymorphism:

  • Type is explicitly parameterized
  • Single copy of source code allows generation of versions that allow multiple types

Think of lists. (See horizontal relationship)

19
Q

Genericity VS Inheritance

Describe Inheritance.

A

Subtype polymorphism:

  • Can use an instance of a subclass wherever a class is expected.

See vertical relationship.