Principles of Programming Languages Final

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/20

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:51 AM on 4/16/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

21 Terms

1
New cards

Chapter 6

2
New cards

What is the key distinction between a primitive data type and other data types?

(A) Primitive data types are always implemented the same regardless of which language you use.

(B) Because primitive data types closely match the architecture (sometimes directly), they are more efficient to process than other data types and take up less space

(C) Primitive data types are not defined in terms of other data types.

(D) All languages have primitive data types.

(C) Primitive data types are not defined in terms of other data types.

3
New cards

Given the following array index of a 5-based array implementation (indexes start at 5), representing an array that has the dimensions 20 x 20 (20 rows of 20 elements each), what is the linear (1D) address or index for the array element below?

Array1[6][7]

(A) 22

(B) 43

(C) 64

(D) 85

(E) 127

(A) 22

4
New cards

Given the following array index of a 3-based array implementation (indexes start at 3), representing an array that has the dimensions 20 x 20 (20 rows of 20 elements each), what is the linear (1D) address or index for the array element below?

Array1[4][5]

(A) 22

(B) 43

(C) 64

(D) 85

(E) 127

(A) 22

5
New cards

What is a key distinction between Rectangular and Jagged Arrays?

(A) A given language will only support one, but not both.

(B) With rectangular arrays every row has the same number of elements and every column has the same number of elements. With jagged arrays there can be rows or columns with varying numbers of elements.

(C) Rectangular arrays are square. Jagged arrays are not square.

(D) Rectangular are implemented as a pointer to just the first array element. Jagged arrays are implemented as pointers to every element.

(B) With rectangular arrays every row has the same number of elements and every column has the same number of elements. With jagged arrays there can be rows or columns with varying numbers of elements.

6
New cards

Given the following array index of a 2-based array implementation (indexes start at 2), representing an array that has the dimensions 10 x 10 (10 rows of 10 elements each), what is the linear (1D) address or index (offset from start address)?

Assume element size (size of data type is 1 byte).

Array1[4][5]

(A) 23

(B) 29

(C) 34

(D) 45

(A) 23

7
New cards

Chapter 7

8
New cards

Given typical operator precedence rules, what would be printed to the console if operands were evaluated from left to right, and all operands had an equivalent precedence level?

____________________________________________________

int no_se (int n1, int n2)

{

return n1 + n2;

}

int se (int n1, int n2)

{

return n1 += n2;

}

int main()

{

int x = 2, y = 2;

int result = se(&x,&y) + x + no_se(x,y);

printf("%d\n", result);

}

____________________________________________________

(A) 10

(B) 12

(C) 14

(D) 16

(C) 14

9
New cards

Given typical operator precedence rules, what would be printed to the console if operands were evaluated from right-to-left, and all operands had an equivalent precedence level?

____________________________________________________

int no_se (int n1, int n2)

{

return n1 + n2;

}

int se (int n1, int n2)

{

return n1 += n2;

}

int main()

{

int x = 2, y = 2;

int result = se(&x,&y) + x + no_se(x,y);

printf("%d\n", result);

}

____________________________________________________

(A) 16

(B) 12

(C) 14

(D) 10

(D) 10

10
New cards

What is a functional side effect?

(A) When a function has parameters and returns something.

(B) When a function does not modify any non-local variables.

(C) When a function modifies any non-local variables.

(D) When a function returns more than one thing.

(C) When a function modifies any non-local variables.

11
New cards

Given typical operator precedence rules, what would be printed to the console if operands were evaluated from left to right, and all operands had an equivalent precedence level?

____________________________________________________

int no_se (int n1, int n2)

{

return n1 + n2;

}

int se (int n1, int n2)

{

return n1 += n2;

}

int main()

{

int x = 2, y = 2;

int result = x + se(&x,&y) + no_se(x,y);

printf("%d\n", result);

}

____________________________________________________

(A) 16

(B) 12

(C) 14

(D) 10

(B) 12

12
New cards

What does it mean to say that a function is referentially transparent?

(A) That function returns more than one thing.

(B) That function accepts 1 parameter and returns 1 thing.

(C) That function does not modify any non-local variables.

(D) That function modifies any non-local variables.

(C) That function does not modify any non-local variables.

13
New cards

Chapters 9-12

14
New cards

What is the difference between an actual and a formal parameter?

(A) A formal parameter is used in a design doc, such as a uml diagram or other documentation, while an actual parameter is what you see in the source code file.

(B) Nothing

(C) A formal parameter includes a type, while an actual parameter can be dynamic.

(D) The formal parameter is the "placeholder" that appears in the subprogram definition, while the actual parameter is the value or address of the actual data that is being passed as a parameter to a subprogram.

(D) The formal parameter is the "placeholder" that appears in the subprogram definition, while the actual parameter is the value or address of the actual data that is being passed as a parameter to a subprogram.

15
New cards

What value would be printed to the console, given the following code, if ad hoc binding were used for passing subprograms as parameters?

____________________________________________________

function main()

{

var x = 10;

function print()

{

display(x)

}

function f1()

{

var x = 15;

f2(print);

}

function f2(some_function)

{

var x = 20;

some_function();

}

f2(print);

}

____________________________________________________

(A) 20

(B) 15

(C) 10

(D) null

(C) 10

16
New cards

What items in the subprogram below would be stored as data and what would be stored as code in an activation record instance?

____________________________________________________

int my_fun ( int x, int y )

{

int z;

z = x + y;

return z;

}

____________________________________________________

(A) Data: x, y, z

Code: return address for calling function

z = x + y

return z

(B) Data: x, y

Code: z = x + y

return z

(C) Data: address of next instruction in caller

x, y, z

Code: z = x + y

return z

(D) Data: x, y, z

Code: z = x + y

(C) Data: address of next instruction in caller

x, y, z

Code: z = x + y

return z

17
New cards

What is an abstract data type?

(A) A user-defined data type where many of the details of the object are hidden from a user, and the user must interact with the object via provided operations.

(B) Any data type that is not a primitive.

(C) A dynamic variable.

(D) A generic data type.

(A) A user-defined data type where many of the details of the object are hidden from a user, and the user must interact with the object via provided operations.

18
New cards

Which of the following concerns is address by inheritance? There can be more than one.

(A) The ability to define new classes in terms of existing ones by allowing them to inherit common parts.

(B) The ability to reuse ADTs.

(C) Initialization of Objects.

(D) Being able to pass generic objects as parameters.

(A) The ability to define new classes in terms of existing ones by allowing them to inherit common parts.

(B) The ability to reuse ADTs.

19
New cards

What does it mean to say that a language uses positional parameter correspondence?

(A) The name of the formal parameter to which an actual parameter is bound is specified with the actual parameter.

(B) The binding of actual parameters to formal parameters is by position.

(C) There can be a variable number of parameters accessed like an array element in the order that they are entered. The corresponding formal parameter is an array preceded by params.

(B) The binding of actual parameters to formal parameters is by position.

20
New cards

What is the central theme for Abstract Data Types (ADT)?

(A) polymorphism

(B) data types

(C) encapsulation

(D) inheritance

(C) encapsulation

21
New cards

What is the difference between a subclass and a subtype?

(A) All classes are subtypes.

(B) Subtypes behave like the parent class while subclasses merely inherit the implementation of the parent class.

(C) All classes are subclasses of the object class, but they can also be subtypes of other user-defined classes.

(D) Subclasses can have multiple inheritance while subtypes can only have single inheritance.

(B) Subtypes behave like the parent class while subclasses merely inherit the implementation of the parent class.