Programming Languages

0.0(0)
studied byStudied by 1 person
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/41

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:11 PM on 12/9/25
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

42 Terms

1
New cards

How many “ init ()”s are allowed in a Python class declaration?

1

2
New cards

In Java and Python, where are the values of instance variables stored?

heap.

3
New cards

In a Python initializer, what is purpose of the “*args” keyword?

Holds the parameters to be sent to the superclass(s).

4
New cards

In Java, what memory area are class variables stored

static area of memory

5
New cards

Which language ensures that the classes at the top of the hierarchy are initialized first?

Java.

6
New cards

Which language supports multiple inheritance?

Python

7
New cards

Which language requires that the “super()” operator be put in the first line of the constructor/initializer body?

Java.

8
New cards

Which language(s) uses the “new” operator to create class or struct instances?

Java

9
New cards

Which of the following is true of a symbol table?

  • A programming language can maintain more than one symbol table (namespace) simultaneously.

  • The environment maintains a symbol table.

  • Both reference counting and garbage collection make use of symbol tables

10
New cards

In heap maintenance, what does coalesce mean?

merge adjacent blocks of available memory.

11
New cards

The storage reclamation method that Go uses is

garbage collection

12
New cards

In C, new storage on the heap is allocated by the

malloc operator

13
New cards

The indicator field is used in

garbage collection

14
New cards

Which language cannot implement the swap procedure?

Java.

15
New cards

Which language does not support pointer arithmetic?

Java

16
New cards

What was the first language to use garbage collection?

Lisp

17
New cards

How many phases does a mark/sweep garbage collection algorithm have?

3.

18
New cards

In Python, storage management uses

reference counting.

19
New cards

Which of the languages below have nested subprograms?

Python, scheme, javascript

20
New cards

An AR for a lexically scoped language with stack-dynamic local variables and subprograms has how many possible field types (hint: include static and dynamic links)?

5

21
New cards

An AR for a non-recursive language with simple subprograms has how many field types?

3

22
New cards

When drawing diagrams of activation records on a runtime stack,

The bottom of the AR is the front and the stack grows in the upward direction.

23
New cards

For a lexically scoped language with nested subprocedures, the chain offset for the use of a variable is calculated by

obtaining the static depth where the variable is used, obtaining the static depth where the variable is declared, and subtracting the latter from the former.

24
New cards

According to Sebesta, what are the characteristics of a language which allows simple subprograms?

No recursion, no nested subprograms or procedures.

25
New cards

Which of the languages below do not need a stack as part of its runtime environment?

Early versions of FORTRAN

26
New cards

In a C/C++/Java-like language, nested blocks

  • create a local scope.

  • can be used to restrict visibility of temporary local variables, thereby increasing program reliability.

  • are often implemented by placing an AR on the runtime stack.

27
New cards

In a language with stack-dynamic local variables

  • activation records are stored on the runtime stack

  • there is one activation record for each procedure activation

  • activation records are connected by dynamic links

28
New cards

In a lexically scoped language with stack-dynamic local variables and nested subprograms,

the static depth for each procedure is calculated by the compiler and is saved.

29
New cards

In a language with stack-dynamic local variables, when a procedure returns

the AR at the top of the stack is popped and the dynamic link of the popped AR points to the front of the next AR on the stack.

30
New cards

Which is not true of the Rust language.

The default return value of a function is zero.

31
New cards
<p>In the code below, the variable “v1” becomes unbound when Line 3 is executed. Show how to modify Line 3 so that this does not happen.</p><p></p>

In the code below, the variable “v1” becomes unbound when Line 3 is executed. Show how to modify Line 3 so that this does not happen.

knowt flashcard image
32
New cards

Rust is a strongly typed language like the Go language. In the above code, the variables v1 and v2 have datatypes. What is the name for the process that determines the datatypes for these variables?

Type inference

33
New cards
<p>The pseudo code below is used for the mark phase of garbage collection. It accepts a pointer to an item on the heap and traverses the entire data structure, marking each memory item as being in use. It assumes all memory blocks are the same size and have two fields that point to other blocks. Supply the names of the two functions with the question marks.</p>

The pseudo code below is used for the mark phase of garbage collection. It accepts a pointer to an item on the heap and traverses the entire data structure, marking each memory item as being in use. It assumes all memory blocks are the same size and have two fields that point to other blocks. Supply the names of the two functions with the question marks.

mark, mark

34
New cards

Name the three phases of the garbage collection algorithm described in the textbook and the garbage collection algorithm.

“clear”, “mark”, and “sweep”

35
New cards
<p>The last line of the Java code below makes a shallow copy of an integer stack given by variable first and assigns it to second. Draw the data structures that are the values of first and second, keeping into account that second is a shallow copy. Also, show what information is on the heap vs the runtime stack.</p>

The last line of the Java code below makes a shallow copy of an integer stack given by variable first and assigns it to second. Draw the data structures that are the values of first and second, keeping into account that second is a shallow copy. Also, show what information is on the heap vs the runtime stack.

knowt flashcard image
36
New cards

Draw the cons-cell diagram for the Scheme expression below. (( 1 2 ) (5 ( 3 4 )))

knowt flashcard image
37
New cards

True or false? The function below is tail-recursive.

def factorial(n):

if n == 0: return 1

else: return n * factorial(n-1)

False.

38
New cards

True or false? The function below is tail-recursive.

def factorial(n, accumulator=1):

if n == 0: return accumulator

else: return factorial(n-1, accumulator * n)

True.

39
New cards
<p>The diagram below shows the free-space list during program execution. We see allocated storage (dark shading), unallocated storage (light shading), variables associated with each allocated storage block, and the pointer structure to maintain the free space.</p><p></p><p>Show what happens when a block C of allocated memory is reclaimed and returned to the free-space list. Draw a picture that shows how free-space is coalesced.</p>

The diagram below shows the free-space list during program execution. We see allocated storage (dark shading), unallocated storage (light shading), variables associated with each allocated storage block, and the pointer structure to maintain the free space.

Show what happens when a block C of allocated memory is reclaimed and returned to the free-space list. Draw a picture that shows how free-space is coalesced.

knowt flashcard image
40
New cards

Draw a picture to show what happens when free-space is compacted.

knowt flashcard image
41
New cards

Tail recursion

A recursive function in which the recursive call is the last statement that is executed by the function. So basically nothing is left to execute after the recursion call

42
New cards

Activation Record (AR)

A contiguous block of storage that manages information required by a single execution of a procedure. When you enter a procedure, you allocate it, and when you exit that procedure, you de-allocate it.

Explore top flashcards