GoConqr has a new look! Let us know what you think.

Flashcards

Semester Test 2

Regan Koopmans COS 333 - English 24 cards

Cards in this deck (24)

  1. 1How is looping and iteration handled in purely functional languages?With recursion.
  2. 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.
  3. 3Name two major forms of abstraction:- Process abstraction.
    - Data abstraction.
  4. 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.
  5. 5Name the type of subprogram that does not produce side-effects.Pure Functions.
  6. 6Name the type of abstraction that subprograms promote:Process abstraction.
  7. 7Give a disadvantage for positional subprogram parameters.They require a programmer to remember the order in which the parameters appear in a function call.
  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. 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.
  13. 13Describe a problem for both the programmer, and the programming language itself, when operator overloading is supported:- For the programmer.
    - For the programming language.
  14. 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
  15. 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.
  16. 16What is a closure?A closure is a function with it's extended referencing environment.
  17. 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.
  18. 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.
  19. 19What are the semantic models of parameter passing?- in mode
    - out mode
    -inout mode
  20. 20What are the implementation models for parameter passing?- pass-by-value
    - pass-by-result
    - pass-by-value-result
    - pass-by-reference
    - pass-by-name
  21. 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.
  22. 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.
  23. 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.
  24. 24What are function pointers called in C#?Delegates.

Information

Description
- COS 333 Flashcards on Semester Test 2, created by Regan Koopmans on 10/10/2017.
Created by
Regan Koopmans
Views
11
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?