opl 3 (the last quizlet i will ever make)

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Parametrically polymorphic subprograms are often called _____ subprograms a. Ad-hoc b. Generic c. Inheritance d. Subtype e. Supertype

. Generic

Which of the following is true of passing multidimensional arrays as parameters? a. In C++ when a multidimensional array is passed to a subprogram the compiler must be able to build the mapping function for that array. b. In C++ subprograms must be compiled with the programs that call them, so passing multidimensional arrays is not possible. c. In Ada unconstrained array types cannot be formal parameters, so passing multidimensional arrays is impossible. d. Because it is an imperative language Fortran can use multidimensional arrays as parameters with no restrictions. e. Java and C# have a built in multi-dimensional array class ready for use.

. In C++ when a multidimensional array is passed to a subprogram the compiler must be able to build the mapping function for that array.

Which of the following is NOT true? a. Ad Hoc Polymorphism is achieved by overloading subprograms. b. Subtype Polymorphism means a variable of a type can access any object of its descendants. c. Parametric Polymorphism is achieved with generic parameters d. A Polymorphic subprogram does not need to take parameters of different types. e. Polymorphism increases the reusability of software.

A Polymorphic subprogram does not need to take parameters of different types.

In Javascript, a function can be assigned to a variable, returned from another function, and be passed as a parameter into another function. Which best describes a Javascript function? a. A first-class value b. A second-class value c. A third-class value d. A fourth-class value e. None of the above

A first-class value

What is true about a protocol? a. Protocols are the abstractions and interfaces of subprograms. b. A protocol is a subprogram's parameter profile and does not act as a return type, even if a function. c. A protocol is a subprogram's parameter profile and acts as the return type as well if the subprogram is not a function. d. A protocol is a subprogram's parameter profile and acts as the return type as well if the subprogram is a function. e. Protocols are another name for subprogram headers.

A protocol is a subprogram's parameter profile and acts as the return type as well if the subprogram is a function.

What is the signature of a subprogram? a. Parameter profile b. Number of the parameters c. Order of the parameters d. Types of the parameters e. All of the above

All of the above

What is/are the main disadvantages of stack-dynamic local variables? a. There is the cost of the time required to allocate, initialize (when necessary), and deallocate such variables for each call to the subprogram. b. Accesses to stack-dynamic local variables must be indirect, whereas accesses to static variables can be direct. c. When all local variables are stack dynamic, subprograms cannot be history sensitive. d. All of the above e. None of the above

All of the above

Which of the following best characterizes ad-hoc polymorphism? a. An ad-hoc polymorphic function will only work on a subset of possible types b. An ad-hoc polymorphic function will generally work on an infinite number of types c. Ad-hoc polymorphism achieves type structure using type parameters d. Ad-hoc polymorphism allows for casting between any arbitrary types e. Ad-hoc polymorphism allows for inheritance from multiple super classes

An ad-hoc polymorphic function will only work on a subset of possible types

Which of the following is true about closures? a. Closures allow program programs to run faster b. Closures can be implemented in all modern programming languages c. Closures tend to clutter up a program and should be avoided d. Closures are an archaic programming tool and are no longer supported in most languages e. Closures are only needed if a subprogram can access variables in nesting scopes and can be called from anywhere

Closures are only needed if a subprogram can access variables in nesting scopes and can be called from anywhere

The process by which a compiler automatically converts a value of one type into a value of another type when it's required by the context is ____ a. Coercion b. Auto-typing c. Type-casting d. Auto-typing e. Default-typing

Coercion

Which of the following is a referencing environment for static-scoped languages? a. Ad hoc binding b. Deep binding c. Shallow binding d. Dynamic binding e. Static binding

Deep binding

What are two things to take into consideration when choosing parameter-passing methods? a. Memory space and efficiency b. Amount of parameters c. Type of parameters d. Efficiency and whether one-way or two-way data transfer is needed e. Direction of data transfer and speed

Efficiency and whether one-way or two-way data transfer is needed

A value in a programming language is said to have ___ status if it can be passed as a parameter, returned from a subroutine, or assigned into a variable. a. First class b. Polymorphic c. Second Class d. Third Class e. SuperClass

First class

What is the difference between formal parameters and actual parameters? a. Formal parameters are the parameters on the prototype, while the actual parameters are the formal parameters during execution of the function b. Formal parameters are the parameters to be passed into a function previously defined, while the actual parameters are the parameters in the subprogram after being bound to the formal parameters during run-time c. Formal parameters are the variable type, actual parameters are the names associated with the variable type d. Formal parameters are the empty parameters in a subprogram header that doesn't get used, while actual parameters are the names of the parameters that get used during run-time e. Formal parameters are the parameters in the subprogram header. Actual parameters are a list of parameters to be bound to the formal parameters of the subprogram which must be included with the name of the subprogram by the subprogram call statements

Formal parameters are the parameters in the subprogram header. Actual parameters are a list of parameters to be bound to the formal parameters of the subprogram which must be included with the name of the subprogram by the subprogram call statements

Which of the following is a difference between procedures and functions? a. Functions return values while procedures do not b. Procedures return values while functions do not c. Functions never produce side-effects while procedures may d. Procedures never produce side effects while functions may e. Functions are math expressions while procedures are more complex computations.

Functions return values while procedures do not

Which of the following statements is incorrect? a. A generic function can work for arguments of many types, generally doing the same kind of work independently of the argument type. b. Ad-Hoc polymorphic functions will only work on a finite set of different and potentially unrelated types. c. Universally polymorphic functions will work on an infinite number of types, given that all the types have a common structure. d. Functions that exhibit parametric polymorphism are called overloaded functions. e. Subtype polymorphism means that a variable of type T can access any object of type T or any variable derived from T.

Functions that exhibit parametric polymorphism are called overloaded functions.

What are the 3 sematic models of parameter passing? a. Inside mode, Outside mode, InsideOut mode b. Static mode, dynamic mode, flex mode c. Formal mode, informal mode, verbose mode d. Value mode, reference mode, value-reference mode e. In mode, Out mode, Inout Mode

In mode, Out mode, Inout Mode

What is NOT true about closures? a. Is not a subprogram b. Is a subprogram and its reference environment c. Static Scoped d. Allows subprograms to be returned from functions e. Allows subprograms to be assigned to variables

Is not a subprogram

Which statement most accurately describes a second-class value? a. It can be passed as a parameter and returned from a subroutine b. It cannot be passed as a parameter c. It is best represented by simple types d. It is best represented by labels e. It can be passed as a parameter, but can't be returned from a subroutine or assigned to a variable

It can be passed as a parameter, but can't be returned from a subroutine or assigned to a variable

What defines a value as third class status? a. It can be passed as a parameter, returned from a subroutine, or assigned into a variable b. It cannot be passed as a parameter c. It can be passed as a parameter but not returned from a subroutine or assigned into a variable d. It can only be assigned a variable e. There is no such thing as third class status, only first and second

It cannot be passed as a parameter

Consider Parameter Passing Methods of Major Languages. Which one of the following statements is NOT correct? a. C provides pass-by-value and pass-by-reference b. Java provides all parameters and Object parameters which are passed by reference. c. Ada provides three semantics modes of parameter transmission: in, out, in out; in is the default mode d. C# provides pass-by-value as default and pass-by-reference specified by preceding both a formal parameter and its actual parameter with reference. e. Python and Ruby use pass-by-assignment (all data values are objects); the actual is assigned to the formal.

Java provides all parameters and Object parameters which are passed by reference.

Which of the following is not a disadvantage of a local stack - dynamic variable? a. Allocation b. De - allocation c. Indirect Addressing d. Subprogram cannot be history sensitive e. No recursion support

No recursion support

Consider the following function and the output. Which of the following best describes the model of transfer? public void change (int x) { x = 5; } public static void main (String[] args) { int x = 1; change(x); System.out.println("Output: " + x); } Output: 1 a. Pass by reference b. Pass by result c. Pass by value d. All of the above e. Not enough information to tell

Pass by value

Which is not a disadvantage of Pass-by-Reference (InOut Mode)? a. Slower access b. Passing process is efficient c. Potential for unwanted side effects d. Unwanted aliases e. None of the above

Passing process is efficient

What is true about generic subprograms in C++? a. Generic parameters must be classes b. Restrictions can be specified on the range of classes that can be passed to the generic method as generic parameters c. Can form wildcard types of generic parameters d. Preceded by a template clause that lists the generic variables, which can be type names or class names e. Generic methods are instantiated only once

Preceded by a template clause that lists the generic variables, which can be type names or class names

The _____ environment binds non-local names to variables in in the lexical environment at the time a closure is created. a. Lexical b. Dynamic c. Binding d. Referencing e. Syntax

Referencing

What does the subprogram call do, and is it is implicit or explicit? a. Describes the interface and actions of the subprogram's abstract; implicit. b. Request that the program be executed; implicit. c. Request that the program be executed; explicit. d. Describes the interface and actions of the subprogram's abstract; implicit. e. Calls out first part of the definition; implicit.

Request that the program be executed; explicit.

Which of the following is not a characteristic of an overloaded subprogram? a. Number of parameters b. Order of parameters c. Same type of parameters d. Different return types e. Same subprogram name

Same type of parameters

Which of the following is true? a. First-class values are prioritized by the compiler over second and third class values b. Third class values can only be passed as a parameter c. Second class values can be returned from a subroutine d. Second class values can only be passed as a parameter e. Primitive types are usually second class values

Second class values can only be passed as a parameter

What is the difference between subprogram definition and subprogram call? a. Subprogram definition describes the interface to and the actions of the subprogram abstraction; Subprogram call is an explicit request that the subprogram be executed b. Subprogram definition is an explicit request that the subprogram be executed; Subprogram call describes the interface to and the actions of the subprogram abstraction; c. Subprogram definition represents the function and parameter types; Subprogram call represents the function call. d. Subprogram definition only has single entry points and always return to the calling function; Subprogram call has multiple entry points and doesn't return to the calling function e. None of the above

Subprogram definition describes the interface to and the actions of the subprogram abstraction; Subprogram call is an explicit request that the subprogram be executed

What is the definition of polymorphic? a. Subprogram takes parameters of different types on different activations. b. Overloaded subprograms provide a particular kind of poly-morphism c. means that a variable of type T can access any object of type T or any type derived from T d. is provided by a subprogram that takes generic parameters that are used in type expressions e. The class form is used for type names

Subprogram takes parameters of different types on different activations.

Which of the following is not true about keyword parameters? a. The name of the formal parameter to which an actual parameter is to be bound is specified with the actual parameter b. Parameters can appear in any order, thereby avoiding parameter correspondence errors c. User must know the formal parameter's names d. The binding of the actual parameters to formal parameters is by position e. Formal parameters can have default values

The binding of the actual parameters to formal parameters is by position

What is true about generic subprograms? a. Only takes parameters that are primitive b. Parameters are the same on different activations c. Variables of Type T can access any object of type T d. The subprogram does not provide parametric polymorphism e. Generics will only work as objects.

Variables of Type T can access any object of type T

What is the value of x, y, and z: void mysteryFunc(int &a, int &b, int &c) { a += 8; b += a / c; c = b + 1; } int main() { int x = 4; int y = 7; int z = 2; mysteryFunc(x, y, z); } a. X= 12, Y=13, Z=14 b. X=4, Y=7, Z=2 c. X=8, Y=4, Z=3 d. X=10, Y=11, Z=12 e. X=0, Y=0, Z=0

X= 12, Y=13, Z=14

Overloaded subprograms provide a particular kind of polymorphism called ___ polymorphism. a. Parametric b. ad hoc c. generic d. subtype e. subclass

ad hoc

Pass by reference are the simplest to implement, only a(n) ______ is placed in the stack a. address b. int c. variable d. argument e. function

address

In C#, when method pointers are made into objects, what are they called? a. delegates b. functions c. parameters d. constructors e. methods

delegates

In C++, default parameters must appear ________ a. first, because parameters are positionally associated b. last, because parameters are positionally associated c. first, because C++ uses keyword parameters d. last, because C++ uses keyword parameters e. nowhere, because they are not allowed

last, because parameters are positionally associated

Typically, coroutines are created in an application by a program unit called the: a. quasi-concurrency b. protocol c. symmetric unit control model d. master unit e. coroutines

master unit

In OOPL, we can encapsulate our subroutine as a method of a simple object, and let the object's fields hold context for the method. An object that plays the role of a function and its referencing environment may variously be called ___. a. abstract class b. parametric object c. polymorphic object d. standard template object e. object closure

object closure

What is a disadvantage of pass-by-value? a. pass-by-value parameters are stored twice and costly to move b. pass-by-value parameters are not changed outside of the subprogram c. pass-by-value parameters are changed outside of the subprogram d. pass-by-value parameters use less storage e. pass-by-value parameters have no disadvantages

pass-by-value parameters are stored twice and costly to move

In most languages, parameter communication takes place through the a. compile-time stack b. run-time stack c. stack d. queue e. priority queue

run-time stack

The parameter profile is also known as the ______? a. signature b. protocol c. header d. prototypes e. None of the above

signature

A subprogram call is: a. the explicit return indicating a specific subprogram has been executed. b. the explicit request that a specific subprogram be executed. c. the explicit request that a specific subprogram be executed in the future after the current program has finished executing. d. None of the above. e. Can be either b or c depending on placement of the call.

the explicit request that a specific subprogram be executed.

In Java, for generic class<T>, T is the ___ variable. a. ad-hoc b. type c. polymorphic d. first-class e. primitive

type


Set pelajaran terkait

IM5 Assessment and Intervention Practice Questions

View Set

Final topics - Concept of Family

View Set

Prin. of Marketing Exam 3 - Chapters 10-14

View Set

fundamentals potential questions

View Set