Chapter 9 and Chapter 11
[C++Access] Select one best choice for your answer, for C++ access control (as discussed in the class). What is the access specification for X, Y, Z defined in A as shown below, in class B, C, and D. Select each from the following choice of: Y is __ in D
B. private
The two fundamental kinds of abstraction in contemporary programming languages are ____ abstraction and ____ abstraction.
B. process, data
___ value can be passed as a parameter, but not returned from a subroutine or assigned into a variable.
B. second-class
In Java, for generic class<T>, T is the ___ variable.
B. type
This programming language _____ enables defining function objects by overloading "operator( )" and also supports closures.
C. C++
Consider C++ class. Which one of the following choices is NOT correct?
C. If stack dynamic, they are referenced through pointers
In Java, if a generic method has two or more restrictions on its generic type, they are added to the extends-clause, separated by _____.
C. ampersand
___ is a subprogram and the referencing environment where it was defined.
C. closure
____ polymorphism is provided by a subprogram that takes generic parameters that are used in type expressions that describe the types of the parameters of the subprogram.
C. parametric
All subprograms are ____ abstractions because they provide a way for a program to specify a process, without providing the details of how it performs its task (at least in the calling program).
C. process
[C++Access] Select one best choice for your answer, for C++ access control (as discussed in the class). What is the access specification for X, Y, Z defined in A as shown below, in class B, C, and D. Select each from the following choice of: Y is __ in B
C. protected
Labels are ___ values in most programming languages as it cannot be passed as a parameter.
C. third-class
___ value cannot be passed as a parameter.
C. third-class
Consider Parameters with Referencing Environment. One complication with parameters that are subprograms appears only with languages that allow nested subprograms. The issue is what referencing environment for executing the passed subprogram should be used. One option is ____.
E. All of the above are options.
Consider C++ class. Which one of the following choices is NOT correct?
E. C++ Constructors can be inherited but cannot be overloaded.
Consider C++ class. Which one of the following choices is NOT correct?
E. Constructors or destructors have return types.
There are several benefits of information hiding. (Note: Program units that use a specific abstract data type are called clients of that type.) Which one of the following statements is NOT correct?
E. One benefit is to make name conflicts less likely, because the scope of variables is extensive and wider.
In Java (versus C++), generic parameters must be classes—they cannot be ____ types.
E. primitive
Consider the following code segment. The function big calls sub1 which calls sub2 which uses x. The value of x is ___ with Static scoping.
A. 3
The common solution for accessing member variables is to provide accessor methods, sometimes called getters and setters, that allow clients indirect access to the so-called hidden data—a better solution than simply making the data public, which would provide direct access. There are a few reasons why accessors are better. Which one of the following choices is NOT correct?
A. Read-only access can be provided, by having a setter method only.
Consider the following code segment. The function big calls sub1 which calls sub2 which uses x. With Static scoping, which one of the following statements is CORRECT?
A. The reference to x in sub2 is big's x.
Consider Type Checking of Parameter. Which one of the following statements is NOT correct?
A. Type Checking is not considered important for reliability.
A(n) ____ data type is a data structure, in the form of a record, but which includes subprograms that manipulate its data.
A. abstract
Syntactically, ____ data type is an enclosure that includes only the data representation of one specific data type and the subprograms that provide the operations for that type.
A. abstract
A(n) ___ is a view or representation of an entity that includes only the most significant attributes.
A. abstraction
The evolution of data ____ began in 1960 with the first version of COBOL, which included the record data structure. The C-based languages have structs, which are also records.
A. abstraction
Overloaded subprograms provide a particular kind of polymorphism called ___ polymorphism.
A. ad-hoc
In Java, restrictions can be specified on the range of classes that can be passed to the generic method as generic parameters. Such restrictions are called ____.
A. bound
As Subroutines display most variation. They are ___ values in all functional programming languages and most scripting languages. They are also ___ values in C# and, with some restrictions, in several other imperative languages, including Fortran, Modula-2 and -3, Ada 95, C, and C++.
A. first-class
In C#, a(n) ____ subroutine is an instance of a delegate type.
A. first-class
In general, 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
___ subroutines in a language with nested scopes introduce an additional level of complexity: they raise the possibility that a reference to a subroutine may outlive the execution of the scope in which that routine was declared.
A. first-class
[C++Access] Select one best choice for your answer, for C++ access control (as discussed in the class). What is the access specification for X, Y, Z defined in A as shown below, in class B, C, and D. Select each from the following choice of: X is __ in B
A. public
13. What would the output of the following code be: function sum() { return this.a + this.b + this.c; } var o = {a: 3,b: 4,c: 5, get average() { return (this.a + this.b + this.c) / 3; } }; Object.defineProperty(o, 'sum', {get: sum, enumerable: true, configurable: true}); console.log(o.average, o.sum);
d. 4,12
16. Which statements about JavaScript objects is correct?
d. All of the above.
4. Which of the following is NOT true about recursion in JavaScript?
d. JavaScript does not allow recursion.
15. Which of the following are primitives in JavaScript?
e. All of the Above
1. Which best describes what type of programming language JavaScript is?
e. All of the above
19. Which statement about ECMA is correct?
e. All of the above
20. Which of the following is not a trend in JavaScript?
e. None of the Above
Accessors provide a form of access to data that is hidden from direct access by clients. ____ is used to initialize parts of newly created objects. ____ is often used to reclaim heap storage that may be used by parts of abstract data type objects in languages that do not do implicit storage reclamation.
B. constructor, destructor
In Java 5.0, it supports for ____ types and methods to Java. The name of a(n) ___ class in Java 5.0 is specified by a name followed by one or more type variables delimited by pointed brackets.
B. generic
Parametrically polymorphic subprograms are often called _____ subprograms.
B. generic
_____ polymorphism is also called explicit parametric polymorphism.
B. generic
_____ polymorphism is usually, though not always, implemented by creating multiple copies of the polymorphic code, one specialized for each needed concrete type.
B. generic
Consider the following code segment. The function big calls sub1 which calls sub2 which uses x. With Dynamic scoping, the value of x is ____.
B. 7
Consider Parameter Passing Methods of Major Languages. Which one of the following statements is NOT correct?
B. Java provides all parameters and Object parameters which are passed by reference.
Consider the following code segment. The function big calls sub1 which calls sub2 which uses x. With Dynamic scoping, which one of the following choices is CORRECT?
B. The reference to x in sub2 is sub1's x.
____ is the process by which a compiler automatically converts a value of one type into a value of another type when that second type is required by the surrounding context.
B. coercion
Consider C++ class. Which one of the following choices is NOT correct?
D. Heap-dynamic classes can have pointer data members that reference stack-dynamic data.
The _______ environment binds the non-local names to the corresponding variables in the lexical environment at the time the closure is created.
D. Referencing
As discussed in the class. Consider the following code segment and the figure for how the passing parameters are being done. Function header: void sub(int a, int b, int c, int d) Function call in main: sub(w, x, y, z) Which one of the following choices is NOT correct?
D. for z by value-result
[C++Access] Select one best choice for your answer, for C++ access control (as discussed in the class). What is the access specification for X, Y, Z defined in A as shown below, in class B, C, and D. Select each from the following choice of: Z is __ in B
D. not accessible
[C++Access] Select one best choice for your answer, for C++ access control (as discussed in the class). What is the access specification for X, Y, Z defined in A as shown below, in class B, C, and D. Select each from the following choice of: Z is __ in C
D. not accessible
An instance of an abstract data type is called a(n) ____.
D. object
In Java, the expression <T extends BoundingType> specifies that T should be a(n) ____ of the bounding type.
D. subtype
Languages that support object-oriented programming usually support ____ polymorphism.
D. subtype
____ polymorphism is fundamental to object-oriented languages, in which classes are said to inherit the methods of their parent classes.
D. subtype
____ polymorphism means that a variable of type T can access any object of type T or any type derived from T.
D. subtype
Java 5.0 supports ____ types which can be used for any collection type of any class components.
D. wildcard
An abstract data type is a data type that satisfies the following conditions. Which one of the following choices is NOT correct?
F. Other program units are not allowed to create variables of the defined type.
Function object or functor is another name for ____ time to time.
F. object closure
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 ___.
F. object closure
17. What would the result be of the following function: let myFunc = (x,y) => { x++; y++; return x + y; }; myFunc(3,4);
a. 9
7. Which statement below best describe block scope?
a. Block scoped variables are only scoped within the block they are declared in.
2. What would be the output of the following code? class Cat { constructor(name) { this.name = name; } speak() { console.log(this.name + ' makes a noise.'); } } class Lion extends Cat { speak() { super.speak(); console.log(this.name + ' roars.'); } } var l = new Lion('Fuzzy'); l.speak();
a. Fuzzy makes a noise, Fuzzy roars
6. Which of the statements below is NOT correct about expressions in JavaScript?
a. JavaScript does not use short circuits in expressions.
12. Which of the following statements about JavaScript functions is NOT correct?
a. JavaScript functions can be hoisted.
14. Variable Hoisting refers to what in JavaScript?
a. The ability to refer to something before it is declared without getting a reference error.
9. What would the result be of the following function: let myFunc = x => console.log(x+5); myFunc(5);
b. 10
10. Which best describes global scope in JavaScript
b. Any variable defined outside of a function is a global variable.
3. Which one of the following statements about JavaScript is NOT correct?
b. JavaScript is white space sensitive
5. If given the following code what would the output be when the program executes the following line: console.log(myvar); var myvar = 'my value'; (function() { var myvar; console.log(myvar); myvar = 'local value'; })();
b. undefined
11. What would the result be if you ran the following code: function makeAdder(x) { return function(y) { return x + y; }; } var add8 = makeAdder(8); var add12 = makeAdder(12); console.log(add8(4)); console.log(add12(5));
c. 12,17
8. _____ is a set of statements to perform a task or calculate a value.
c. Procedure
18. Fill in the blanks: ______ via functions, allow inner functions to have access to outer functions variables allowing ______
c. lexical scoping, closures