Introduction Flashcards

1
Q
  1. In general what are records?
  2. What is an example in C?
  3. What is the point of a record?
  4. Give an ADT example of a record
  5. What is the “state” of a record
A
  1. Several types of data stored together (a collection of fields, or attributes)
  2. a struct
  3. The point is to treat a number of pieces of different data types as a unit
  4. We could make a stack and pass it to a method as a single entity
  5. The set of values at any given time defines the state of that structure
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In general what is a class?

What are objects?

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

What is an instance variables and methods?

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

What is the difference between a class and a record?

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

In general what is an ADT?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
A
  1. Nothing to stop outside code from changing stack internals
  2. The code isn’t as generic as it could be(the type of the elements inside the stack has to be defined at compile-time)
  3. What we want from an ADT is indepence of interface and implementation (at least in C, separating the header from the implemnetation gives an appears of that…)
  4. From an ADT standpoint, this is not ecapsilated(anyone can alter stack internals)
    • An OO approach can trun this into an active data structure by combining the valid operations(of stack, e.g, push, pop) with the data itself
    • An object takes requests from outside code, but the operations changing the state of the data structure are controlled by the object itself
    • Objects are encapsulated and make strong use of data higin(thus protecting the internals)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In general what is the idea of messaging?

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

In general what are methods?

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

In general what do classes do and what is their general relationship?

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

What do classes define?

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

What can subclasses do to any of the methods of it’s superclass?

A

use, modify, replace

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

In terms of objects, what is a component?

A

One object contains another

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

In general how are the structures of classes viewed?

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

If an object is sent a message, which object/class runs the method?

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

In general, what is binding?

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

In general, what is dynamic binding?

What is static binding

A

Dynamic = happens at run time

Static = happens at compile time

Dynamic binding is basically how a superclass works, a superclass can contain any intance of that class or any other class that is a descendant

17
Q

Explain if the following lines of code are legal and why.

s.giveInterest();

a=s;

Test.aMethod(s);

boolean x = a.validate(); x = s.validate();

a.giveInterest();

s = (SavingsAccount) a;

A
18
Q

In the code below(blue) why is this unsafe and what is the proper way?

A
19
Q

What is Method-message mapping?

A