Week 9- Implementing Subprogram Flashcards

1
Q

What are formal parameters?

A

Variables defined by a subprogram to accept values.

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

What is the general process of a subprogram call and return?

A

Save status, pass parameters, execute, restore status, and return.

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

What are actual parameters?

A

Real values passed to the subprogram.

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

What are stack-dynamic local variables?

A

Variables allocated/deallocated on the runtime stack.

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

What is an overloaded subprogram?

A

A subprogram with the same name but different parameter lists.

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

What is ad hoc polymorphism?

A

Subprograms operate on different types based on actual parameters.

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

What is a coroutine?

A

A subprogram with multiple entry points allowing cooperative multitasking.

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

What is in an activation record instance (ARI)?

A

Caller status, parameters, return address, return value, temporaries.

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

What are the two parts of a simple subprogram’s AR?

A

Code part and non-code part (local variables and data).

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

What is the first action a caller must perform in the linkage process?

A

Create an activation record instance.

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

What does the caller do to the current program unit’s execution status?

A

Saves it.

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

What is passed to the called subprogram after parameters?

A

The return address.

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

What is the first action in the callee’s prologue?

A

Save the old EP in the stack as the dynamic link.

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

What does the callee do to the execution status of the caller?

A

Restores it.

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

What happens to the local variables in the callee’s prologue?

A

They are allocated.

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

What happens to out-mode parameters during the callee’s epilogue?

A

Their values are moved to the corresponding actual parameters.

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

What happens to the stack pointer in the callee’s epilogue?

A

It is restored to the value of the current EP minus one.

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

What does ARI stand for?

A

Activation Record Instance.

18
Q

What additional ARI information is saved in a recursive call?

A

Return address and dynamic link.

19
Q

What is the dynamic chain in the context of ARIs?

A

The collection of dynamic links.

20
Q

How is an ARI for a nested subprogram found?

A

By finding the correct ARI in the stack and using the local offset.

21
Q

What is a static chain?

A

A chain of static links pointing to static parents.

22
Q

Define static depth.

A

The depth of a subprogram’s nesting in the outermost scope.

23
Q

What is a local offset?

A

The distance from the beginning of an ARI.

24
Q

What is a block in programming?

A

A user-specified local scope.

24
Q

What advantage do blocks provide?

A

Variables cannot interfere with others of the same name.

25
Q

Which has faster references: deep or shallow access?

A

Shallow access.

25
Q

What is deep access?

A

Searching through ARIs of active subprograms for variables.

26
Q

What is shallow access?

A

Using separate stacks for each variable name.

27
Q

What are parameterized abstract data types also known as?

A

Generics or templates.

27
Q

What is encapsulation in programming?

A

A construct that bundles the data and the methods that operate on the data, restricting direct access to some of the object’s components.

28
Q

What is abstraction?

A

A representation of an entity that includes only its most significant attributes.

29
Q

What are the two types of abstraction fundamental in computer science?

A

Process abstraction and data abstraction.

30
Q

What is an ADT?

A

An Abstract Data Type is a type whose implementation is hidden and can only be manipulated through a defined set of operations.

31
Q

What is a user-defined ADT?

A

An ADT where the representation is hidden, and only operations defined in the type’s definition are allowed.

32
Q

What are the advantages of hiding data in an ADT?

A

Increased reliability, reduced name conflicts, and enhanced modifiability.

33
Q

What is an example of a language-defined ADT?

A

Floating-point type.

34
Q

What are the benefits of having a single syntactic unit for type definitions and operations in ADTs?

A

It organizes the program better and enhances modifiability.

35
Q

How do access controls like private and protected enhance encapsulation?

A

They restrict access to the internal details of the data structures.

36
Q

Can abstract types be parameterized?

A

Yes

37
Q

Why is it important to separate the specification of a type from its implementation?

A

To allow modifications to the implementation without affecting the clients using the type.

38
Q

What is a key feature of a stack ADT?

A

It only allows access to the data element at the top.

38
Q

What operation is commonly used as a getter for the top element in a stack?

A

pop().