CSC 388 Final

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Consider the following program:procedure Main is A : Integer; B : Integer; procedure Sub1(X: Integer) is B, C : Integer; begin B := 2; C := 3; A := B + C; end; begin A := 1; B := 1; Sub1(B); end; What is the reference to B in the expression A : = B + C (in terms of chain-offset/local offset)?

(0,4)

Which of the following are terminal symbols in the following grammar rule? <expr> --> <expr> + <term> | ( <expr> )

+ (and)

Which of the following operators are usually right associative in C-based languages?

++ --

For the deep access method, which of the following are true?

-Accesses to nonlocal variables is faster than with the shallow access method -Subprogram linkage is faster than with the shallow access method -Subprogram linkage is slower than with the shallow access method -Accesses to nonlocal variables is slower than with the shallow access method

Which of the following statements are true regarding activation records?

-Activation record is a noncode part of a program -A recursive program may have several activation record instances on the stack -Activation record instance is a concrete example of an activation record

Side effects usually occur when a function:

-Changes some of its parameters -Changes a global variable

Which of the following is true for coroutines?

-Coroutines have multiple entry points -Coroutines must be history sensitive -Only one coroutine executes at a given time

Which of the following is true regarding static scoping?

-In static scoping, the scope of a variable can be determined prior to execution -In static scoping, program designers could use more globals than necessary. -In static scoping, some variable declarations could be hidden from some other code segments.

Which of the following data items are usually stored in an activation record?

-Local variables -Return value for a function (when the activation record corresponds to a function) -Return address

Aliases can be created by which of the following language constructs?

-Pointers and reference variables -The union types of C and C++

Which of the following is a problem with dynamic scoping?

-Readability -Static type checking may not be possible -Access to nonlocal variables takes longer

When the system uses static chain to access nonlocal variables, which of the following are true?

-References to variables in scopes beyond the static parent cost more than references to locals -Nonlocal variables are stored in activation record instances of static ancestors

Which of the following statements are true for a LL algorithm?

-The algorithm produces a leftmost derivation -The algorithm is top-down -The algorithm scans the input from left to right

Which of the following are disadvantages to local stack-dynamic variables in subprograms?

-The cost of allocation, initialization, and deallocation -Access to stack-dynamic variables is indirect -Subprograms cannot be history-sensitive

Which of the following statements are true for a grammar which has the following rules? A --> Ab A --> bB A --> bC

-The grammar is not top-down parsable -The grammar is left recursive

Which of the following are advantages to pass-by-reference?

-There is no need to copy actual parameters to the storage area of corresponding formal parameters -No additional storage is required for storing formal parameters

Which of the following statements are true regarding unions?

-Unions are potentially unsafe constructs -Unions can be used to create aliases -Unions are not included in C#

Suppose a=3, b=2, c=1. What is the result of the following expression in C89? a > b > c

0

What is the weakest precondition for the following assignment statement? x = 2 * (y - x) + x {x > 10}

2y - x > 10

Procedure A has static depth 3 and defines a variable which is visible in a nested subprocedure B. The nesting depth between procedure A and procedure B is 1 (that is, B is directly nested inside A). What is the static depth of B?

4

Which of the following are nonterminal symbols in the grammar rule? <expr> --> <expr> + <term> | <expr> - <term> | <term>

<term> <expr>

Which of the following are valid identifiers in Scheme?

?? /*

A lambda expression is used to create:

A nameless function

The pairwise disjointness test applies to:

A non-left recursive grammar

What is the minimal collection of control statements that is enough to code an algorithm that can be expressed by a flowchart?

A two-way selection and a logically-controlled iteration

In which of the following languages do all operators have the same level of precedence?

APL

Which of the following languages does not allow mixed-mode assignment?

Ada

Which language treats enumeration variables like integer variables (arithmetic operators are legal on enumeration variables and an enumeration variable can be assigned a value outside its defined range)?

C

Which language supports both explicit heap-dynamic and stack-dynamic objects?

C#

Which language supports both rectangular and jagged arrays?

C#

Which of the following languages allow only Boolean (not arithmetic) expressions for loop control in the for statement?

C# Java

Which of the following languages specify array index range checking for arrays?

C# Java

What is the name of the multiple selector in Scheme?

COND

What does the break statement do in C and C++?

Causes the innermost loop (or switch) to be exited

In a static scoped language that uses static chaining as an implementation technique, references to non-local variables can be represented as:

Chain offset/Local offset

Which of the following are skipped by the lexical analyzer?

Comments Blanks

What does the function cons do?

Constructs a dotted pair from two parameters

What does the function list do?

Constructs a list from parameters

Which of the following is not a characteristic of the overall cost of a programming language?

Cost of the host computer

Which loops specify the initial and terminal values of the loop variable?

Counter-controlled loops

The LHS of a context-free rule consists of

Exactly one nonterminal symbol

Which variables are created using operator new?

Explicit heap-dynamic

Which of the following languages uses column major order?

Fortran

What did Chomsky propose?

Four classes of grammars, including context-free grammars

What kind of language is LISP?

Functional

Which languages use recursion rather than iteration to control repetition?

Functional

What is aliasing?

Having two or more disctinct referencing methods, or names, for the same memory cell

Which of the following array types can grow and shrink during program execution (please, remember that although subscript ranges of some array types are dynamically bound, they remain fixed during the lifetime of the array)?

Heap-dynamic arrays

What category of programming languages best fits the von Neumann computer architecture?

Imperative

What is coercion?

Implicit (initiated by the compiler) conversion

Which of the following language deficiencies was one of the main factors behind the advent of new software development methodologies in 1970s?

Inadequacy of control statements

Which of the following does not belong to an attribute grammar?

Inference rules

Languages with dynamic type binding are usually implemented using:

Interpreters

The C# switch statement differs from that of C in that:

It disallows the implicit execution of more than one segment

The handle of any rightmost sentential form is:

Its leftmost simple phrase

The generic methods of which language support wildcards?

Java

Which of the following languages does not provide built-in-pattern matching operations (the language, although, has pattern matching capabilities included in its class libraries)?

Java

Which of the following languages does not support user-defined operator overloading?

Java

In which languages can nested if statements be interpreted ambiguously?

Java C

Which of the following languages allow nested subprograms?

JavaScript Ada

Which of the following languages allow nested subprograms?

JavaScript Ada Fortran 95

Which languages support the operator "==="?

JavaScript PHP

What does the following code illustrate? float* ptr1 = new float; float* ptr2 = new float; ptr2 = ptr1;

Memory leakage

The complexity of general parsing algorithms for any unambiguous grammar is:

O(n^3)

Which of the following languages do not require parameter type checking?

PHP Perl JavaScript

Aliases can be created by which of the following parameter passing methods?

Pass-by-reference

Which parameter passing method would be preferred (in terms of storage) when a large array is to be passed to a subprogram that does not modify it?

Pass-by-reference

Which loops are guaranteed to be executed at least once?

Posttest logically controlled loops

Which language uses indentation to specify compound statements?

Python

Which of the following languages allows functions/methods to be returned from functions/methods:

Python

The existence of too many ways to accomplish a particular operation in a programming language can affect:

Readability

When applied to a list, what does the function car do?

Returns the first element of a list

When applied to a list, what does the function cdr do?

Returns the remainder of a list

What kind of derivation is produced by bottom-up parsers?

Reverse of a rightmost

Which of the following languages does NOT have a goto statement?

Ruby

Which of the following languages support dynamic scoping?

SNOBOL4 APL

Elliptical reference is one in which:

Some record names are omitted

The language that a compiler translates is called what?

Source language

Consider the following definition in C: void f() { int arr[20]; .... } What kind of variable is arr?

Stack-dynamic

Which variables are bound to memory cells before program execution and remain bound to the same memory cell during program execution?

Static

Which of the following errors can be detected by a lexical analyzer?

Syntax errors in tokens

Which programming domain best describes C?

Systems programming

Which of the following are phrases of the right sentential form T * F + id given the grammar: E --> E + T | TT --> T * F | FF --> ( E ) | id

T * F + id T * F id

A dynamic link points to:

The bottom of the activation record instance of the dynamic parent

A static link points to:

The bottom of the activation record instance of the static parent

In deep binding, the referencing environment for executing a subprogram passed as a parameter is:

The environment of the definition of the passed subprogram

What prevented Ada from becoming popular in its early days?

The high cost of compilers

The purpose of left factoring is

To convert a grammar into one that is top-down parsable

Which of the following is not a factor in writability?

Type checking

(Select all that apply) Which of the following sentences cannot be derived using the following EBNF: <expr> --> <term> {(+ | -) <term>}<term> --> <factor> {(* | /) <factor>}<factor> --> a | b | c

a * (b + c) (a + b) + (a + c)

A token is

a category of lexemes

The start symbol in a grammar is

a nonterminal

If a sentential form produces 2 or more different parse trees then the grammar is

ambiguous

Where was Scheme created?

at MIT

Which of the following conversions are narrowing?

double to float int to byte

All recursive functions are tail recursive.

false

Purely functional languages do not enjoy the property of referential transparency.

false

What kind of array is defined in the followig Java definition: int[] a = new int[10];

fixed heap-dynamic array

If functions are compiled separately from the main program in C++, which of the following function definitions are valid?

void fun(int mat [ ] [10]) {...} void fun(int mat [5] [10]) {...}

Which of the following expressions allow short-circuit evaluation?

x && y x || y


Kaugnay na mga set ng pag-aaral

QUIZ - Unit 5 - National Brokerage

View Set

Substance Use and Misuse - EXAM 2 - Dr.Johnny Moore

View Set

Anatomy & Physiology Exam 3 (Ch. 8-10)

View Set

Economic Systems: Adam Smith and the US Economy

View Set