Chapter 12 Flashcards

1
Q

Which languages are considered pure OOP languages?

A

Smalltalk + Ruby

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

What must any OOP language support?

A

ADTs
Inheritance
Polymorphism

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

What is good about inheritance?

A

Increases productivity from reuse

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

Problem with basic ADTs?

A

Difficult to reuse without some changes

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

What are some OO concepts?

A

ADTs aka classes
Class instances aka objects
Class inheritance aka subclass/ derived class + superclass . parent class
Subprograms defining operations on objects aka methods aka member functions

Call to methods aka messages
Collection of object methods aka message interface
2 part messages aka method name + destination object (myObject.print(12))
Access control in inheritance
Overriding methods

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

What are the 2 kinds of variables in a class?

A

Class variable ( one per class )
Instance variables ( one per object )
Same with methods

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

Disadvantage of inheritance?

A

Complicate maintenance, interdependencies among classes

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

What type of binding is a polymorphic reference?

A

Dynamic Binding

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

What is a abstract method?

A

Only define protocol, no definition

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

What is a abstract class?

A

Include at least one abstract method
Cannot be instantiated

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

What are some design issues for OOP languages?

A

Single vs multiple inheritance
Dynamic vs static binding
Nested classes
Are subclasses subtypes?

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

What is good and bad when everything is an object?

A

Good: Elegance + pure uniformity
bad: simple operations are slow

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

What is good and bad about adding objects to a complete typing system?

A

Good: simple operations are fast
Bad: Results in confusing type system

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

Good and Bad about using imperative typing system for primitives and making everything else objects? (Java)

A

Good: Simple operations are fast, but typing system remains relatively small
Bad: 2 type systems have to mix

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

When is a derived class a subtype?

A

If is has a “is-a” relationship with the parent class

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

Good and Bad of Multiple inheritance?

A

Good: convenient + valuable
Bad: Complexity, name collisions. potential inefficiency

17
Q

What is the problem with diamond inheritance?

A

It always produces a type problem

18
Q

Should every binding of a message to a method be dynamic?

A

Only dynamic binding is inefficient
No dynamic binding = no advantages

19
Q

What is a problem with nested classes?

A

Deciding visibility of members

20
Q

When do you use nested classes?

A

When a new class is only needed by one class

21
Q

What are the 2 object initialization types?

A

Explicit and implicit( only if there exists a default constructor in the language )

This can also lead to explicit + implicit initialization of subclass objects

22
Q

Does Smalltalk have any characteristics of imperative languages?

A

No. Its a pure OOP language

23
Q

How are objects accessed in Smalltalk?

A

Typeless reference variables

24
Q

Is Smalltalk deallocation implicit or explicit?

A

implicit
Uses a garbage collector which can be slow

25
Do Smalltalk bind messages to methods statically or dynamically?
Dynamically
26
How does dynamic message binding impact Smalltalk language evaluation?
Decreases readability but increases writability and reliability
27
How does the lack of multiple inheritance affect the language evaluation criteria?
Decreased writability and readability, increases reliability (no diamond problem)
28
What is one of the most widely used OOP languages?
C++
29
How is C++ better than Smalltalk?
Faster execution
30
2 types of inheritance access controls in C++?
Public derivation Private derivation
31
When does a designer decide what type of message binding he will use?
At class design time
32
Which is faster? Dynamic message binding or static message binding?
Static
33
How do you "signal" dynamic binding in C++?
virtual
34
Which draw will be called if objects are allocated from the stack? (static) Circle circ; // Allocates a Circle object from the stack Rectangle rect; // Allocates a Rectangle object from the stack rect = circ; // Copies data member values from circ object rect.draw();
The draw from rectangle
35
Does Java support single or multiple inheritance?
Only single
36
Does Java use dynamic or static message binding?
Only dynamic
37
What is the advantage of using "new" when overriding a methods definition in C#?
No accidental method hiding
38
What does "override" keyword do to readability writability and reliability?
Reliability + Readability = increased Writability = no significant impact
39
What are the implications of all data being private in Ruby classes, in terms of the language evaluation criteria?
Decreased writability, increased reliability