Fichas
Semester Test 2
Fichas del conjunto (24)
- 1How is looping and iteration handled in purely functional languages?With recursion.
- 2In Ruby, classes are dynamic. Suggest how this might affect the readability of Ruby.This is detrimental to readability. Rather than having one single place for the definition of a class, we must trace through the program to determine the nature of the class.
- 3Name two major forms of abstraction:- Process abstraction.
- Data abstraction. - 4How does Python handle ambiguity in control structures? How does Ruby?Python uses whitespace and indentation to resolve ambiguities.
Ruby uses explicit "end" reserved words to demarcate control structures. - 5Name the type of subprogram that does not produce side-effects.Pure Functions.
- 6Name the type of abstraction that subprograms promote:Process abstraction.
- 7Give a disadvantage for positional subprogram parameters.They require a programmer to remember the order in which the parameters appear in a function call.
- 8Describe how Ruby implements operators.Ruby has special member functions that can be implemented/overloaded to allow operators to be used on user-defined types.
- 9Differentiate between formal parameters and actual parameters.Formal parameters are the set names used in the function definition.
Actual parameters are the set of actual values that are sent in a funtion call. - 10Describe one disadvantage associated with pass-by-value parameters.Pass-by-value parameters require parameters to be copied into local variables, which is slow for non-scalar types, and inefficient in memory.
- 11Explain what the purpose of naming encapsulation is:Naming encapsulation, sometimes called "namespaces" define a name scope. This is to avoid name collisions in large programming projects, and to logically group program files into packages and modules.
- 12Contrast the support for unconditional branching in C and Java.C supports the goto statement, and therefore arbitrary unconditional branching. Java supports the continue and break statements, which can only be used in particular circumstances.
- 13Describe a problem for both the programmer, and the programming language itself, when operator overloading is supported:- For the programmer.
- For the programming language. - 14Give an example of a situation in which the lack of short-circuit operators cause a problem in a user's program code:If we are using a loop to search a dynamic list structure:
while(ptr != null && ptr->value != 5) {}
we need short circuit to terminate before a check is performed - 15Contrast how C++ and C# handle array dimensions when arrays are passed to subprograms:C++ requires that the exact dimensions of an array are specified in the definition of the subprogram.
- 16What is a closure?A closure is a function with it's extended referencing environment.
- 17What is a guarded command?A guarded command is an alternative control structure proposed by Dijkstra that maps a condition to an expression. It has positive theoretical qualities over conventional control structures.
- 18What characteristics does every subprogram (besides coroutines) have in common?- has a single entry-point.
- caller is suspended during the execution of the subprogram.
- control always returns to the caller when the subprogram terminates. - 19What are the semantic models of parameter passing?- in mode
- out mode
-inout mode - 20What are the implementation models for parameter passing?- pass-by-value
- pass-by-result
- pass-by-value-result
- pass-by-reference
- pass-by-name - 21How can procedures return results?VIA VARIABLES:
- if there are variables that are not the formal parameters, but are still in the scope (eg global variables).
- if formal parameters are references to variables in the caller's scope. - 22Give a disadvantage of pass-by-value parameters?They require that a copy be made of all passed parameters. This may utilize memory unnecessarily, and is potentially very slow on non-scalar data types, such as objects or complex data structures.
- 23What is a coroutine?A coroutine is a subprogram to which flow control is passed cooperatively to the callee, and for which execution can be paused and resumed to run other subroutines in tandem with quasi-concurrency.
- 24What are function pointers called in C#?Delegates.
Información
- Descripción
- - COS 333 Fichas sobre Semester Test 2, creado por Regan Koopmans el 10/10/2017.
- Creado por
- Regan Koopmans
- Visitas
- 11
- Valoración