Font size
WorksheetsCPSC 360 - Exam 2
Total questions: 122
Worksheet time: 2hrs 49mins
Name
A string of characters used to identify some entity in a program
The memory address with which a variable is associated
Determines the range of values and sets of operations that are defined for the value
The contents of memory cells associated with a variable
If a name's length limit is too short, it cannot be connotative. This is a detriment to...
(a)
Case sensitivity for names distinguish names that look similar as different. This is a detriment to...
(a)
If predefined names include uppercase and lowercase letters, it becomes more difficult to write correct programs. This is a detriment to...
(a)
Reserved Word
A word you have to wait in line for before being able to use it in a program
The name of a variable already used in a given scope
A word in a programming language that cannot be used as a name
A word in a programming language that can be used as a name, but it's not advisable to do so
Programs are more readable, since reserved words name actions preformed by the program. This is a benefit to...
(a)
If there are too many reserved words, it becomes more difficult for the programmer to come up with names. This is a detriment to...
(a)
Keyword
The name of a variable already used in a given scope
A reserved word usable only in certain contexts
A key used to access some value
A word in a programming language that cannot be used as a name
Address
A string of characters used to identify some entity in a program
The memory address with which a variable is associated
Determines the range of values and sets of operations that are defined for the value
The contents of memory cells associated with a variable
True or False: A variable may have different addresses at different times
(a)
True or False: Addresses are also known as the R-Value
(a)
True or False: Addresses are also known as the L-Value
(a)
Aliases
Different methods of pointing to an object in the stack
Multiple addresses pointing to the same variable
Different methods of pointing to an object in the heap
Multiple addresses refrencing the same variable
Aliases allow a variable to have its value changed through different aliases. This is a detriment to...
(a)
Type
A string of characters used to identify some entity in a program
The memory address with which a variable is associated
Determines the range of values and sets of operations that are defined for the value
The contents of memory cells associated with a variable
Value
How long the variable exists
The contents of memory cells associated with a variable
Determines the range of values and sets of operations that are defined for the value
The range of statements where the variable is visible
Which language uses mixed case names?
Fortran
Perl
F#
C#
In what language is the names Rose, rose, and ROSE all distinct names?
(a)
What language illustrates that too many reserved words would be an issue for writability?
(a)
This user based language has a decimal type. Although it is quite space inefficient, is also comes with great accuracy. This language is...
(a)
Consider the following C++ assignment statement:
count = count + 5
When is the type bound to count?
(a)
Consider the following C++ assignment statement:
count = count + 5
When is the possible range of values bound to count?
(a)
Consider the following C++ assignment statement:
count = count + 5
When is the meaning of + bound?
(a)
Consider the following C++ assignment statement:
count = count + 5
When is the representation of the literal 5 bound?
(a)
What language uses keyword var to determine the type through Type Inference?
(a)
What type of binding does Java rely on to determine variable types?
(a)
Java uses garbage collect to remove unused objects in the heap, unlike C which requires the user to manually remove it. This is because Java prioritizes ___________ over __________.
(a)
C-Based Languages use stack dynamic variables, in order for (a) to be possible
In C and C++, static variables can be initialized with the static keyword. These variables never change their ________ in ______.
(a)
Which language has dynamic variable binding?
Ada
Python
Scheme
C++
JavaScript and Python have support for dynamic variables. This provide great ___________, but comes at an __________ cost due to type checking and interpretation
(a)
Static variables in _ improves efficiency due to direct addressing, but has a lack of flexibility since there can be no recursion or other instances of this variable
(a)
Local variables in C are _____ _______, meaning that storage bindings are created for variables when their declaration statements are elaborated
(a)
Stack dynamic variables conserve _______, but are ___________ __________ since indirect addressing is required
(a)
________ ____ _______ variables in C and C++ are allocated and deallocated by the user. Their type is bound during compile time.
(a)
In C++, the allocation operator is ___, and the deallocation operator is ______ followed by the name of the pointer pointing to the deleted object.
(a)
Explicit heap dynamic variables are useful for making certain data structures, but heap management is ______, and pointers and references are _________ to use.
(a)
________ ____ _______ variables in JavaScript are bound to heap storage when they are assigned values
(a)
For most programming languages, binary operators are...
(a)
Operator Precedence Rules define the (a) in which the operators of different precedence levels are evaluated
Consider this statement in Ruby:
-5 ** 2 + 3 % 4
Which operator has the highest precedence?
-
**
+
%
Consider this statement in Ruby:
-5 ** 2 + 3 % 4
Which operator has the second highest precedence?
-
**
+
%
Consider this statement in Ruby:
-5 ** 2 + 3 % 4
Which operator has the second lowest precedence?
-
**
+
%
Consider this statement in Ruby:
-5 ** 2 + 3 % 4
Which operator has the second lowest precedence?
-
**
+
%
Consider this statement in a C-based language:
-17 * 38
Which operator has the highest precedence?
-
*
++
--
Consider this statement in a C-based language:
-17 * 38
Which operator has the lowest precedence?
-
*
++
--
Consider these statements in a C-based language:
--sum;
total++;
Which operator has the lowest precedence?
-
*
++
--
Consider these statements in a C-based language:
--sum;
total++;
Which operator has the highest precedence?
-
*
++
--
Consider the following C program:
a + b * c
What is the equivalent in Lisp?
(* c (+ a b))
(* a (+ b c))
(+ a (* b c))
(+ c (* a b))
Consider the following program and function definition:
a = 10;
b = a + fun(a);
int fun(int &a) {
a = a*2;
return a;
}
What is b equal to?
(a)
Consider the following program and function definition:
a = 10;
b = a + fun(a);
int fun(int a) {
a = a*2;
return a;
}
What is b equal to?
(a)
What is an operator with multiple uses?
(a)
In this language, you can specify that using the * operator with an integer and an integer array means multiplying each value in the array by the integer
(a)
Operator overloading can be harmful to (a) , since nothing is stopping the + operator to mean multiplication
What type of conversion do these Java statements demonstrate?
float real = 4.2;
int integer = (int)real;
(a)
What type of conversion do these Java statements demonstrate?
int integer = 42;
float real = integer;
(a)
What is an expression with operands of different types?
(a)
Implicit type conversion
(a)
In most programming languages, all numeric types are coerced using ________ coercions. A disadvantage is the decrease in the ____ _____ detection ability.
(a)
In C-based languages, explicit type conversions are called (a) .
Compares the value of its two operands
(a)
In JavaScript, what does this evaluate to?
"7" == 7
True
False
In JavaScript, what does this evaluate to?
"7" === 7
True
False
Relational operators always have (a) precedence than arithmetic operators.
To avoid confusion between assignment and equality, ALGOL 60 and Ada use (a) instead of =.
In C-based languages, JavaScript, and Ruby, the statement below is equivalent to the compound assignment operator:
a = a + b;
a (a) b;
C-based languages, Perl, and JavaScript have unary assignment operators. In the following:
a = ++b;
b is first ___________, then ________.
(a)
C-based languages, Perl, and JavaScript have unary assignment operators. In the following:
a = b++;
b is first ________, then ___________.
(a)
In the C-based languages, Perl, and JavaScript, the assignment statement produces a result and can be used as an operand.
int o;
bool p = ((o = 5) % 2 == 0);
What is the value of p?
(a)
Consider the multiple target assignment statement in Perl or Ruby:
($o, $p) = (4, 20);
($o, $p) = ($p, $o);
What is the value of p?
(a)
In which language will the following statement throw an error?
int i = 9.6;
C
C++
Java
Ada
In which language will the following statement throw an error?
float f = 5;
C
C++
Java
Ada
C-based languages, Perl, and JavaScript have unary assignment operators. In the following:
-c++;
c is first ___________, then _______.
(a)
In Ada, array elements are accessed like this:
int val = chart(i);
This is detrimental for readability because you can't tell if it's an _____ or a ________.
(a)
In Perl, when referring to an array object, you use _. When accessing a scalar object in said array, you use _.
(a)
In this type of array, subscript ranges are statically bound and storage allocation does not change.
(a)
In this type of array, subscript ranges are statically bound, but the allocation is done at declaration elaboration time during execution.
(a)
In this type of array, subscript ranges are statically bound, allocation is done at declaration elaboration time during execution, and its location is in the heap.
(a)
In this type of array, the binding of subscript ranges and storage allocation is dynamic and can change any number of times during the array’s lifetime.
(a)
Static arrays are _________ due to no dynamic allocation being required, but ___________ is lost since the array is in a fixed location during execution.
(a)
Fixed stack dynamic arrays are more _____ efficient than static, but less ____ efficient due to the allocation needed to create the array in memory.
(a)
Fixed heap dynamic arrays are ________ since the array's size always fits the problem, but are not ____ efficient since it has to allocate memory from the heap.
(a)
Heap dynamic arrays are ________ since they can change size during execution, but are not very _________ since space needs to be allocated and deallocated constantly.
(a)
In this language, four basic arithmetic operators are defined for vectors, as well as so many other single character operations that can be preformed on arrays.
(a)
Take this APL statement:
A +.× B
This is the sum of the inner product of A and B. If A and B are matrices, this expression specifies the ______ ______________ of A and B.
(a)
In what languages is this array valid?
char arr[3][8];
C
C++
C#
Java
In what languages is this array valid?
char arr[3, 8];
C
C++
C#
Java
Consider this array in python:
array10d = [9, 19, 21, 3, 11, 16, 5, 14, 9, 19]
which elements are referenced by array10d[3:6]?
(a)
A (a) is an aggregate of data elements in which the individual elements are identified by names and accessed through offsets from the beginning of the structure.
Elements of a heterogenous array are often _________, while a record has its elements reside in ________ memory locations.
(a)
While arrays use _______ to reference elements, records use ___________.
(a)
____ ________ is the activity of ensuring that the operands of an operator are of compatible types.
(a)
Dynamic type binding requires type checking at run time, which is called _______ ____ ________.
(a)
In the original version of C, if you added a float and an int, the result would be an (a) .
A _______ type variable has a range of values that consists of ______ _________ and a special value, ___.
(a)
A pointer can be used to access a location in the area where storage is dynamically created, the (a) .
__________ is used to set a pointer variable’s value to some useful address. _____________ yields the value stored at the location represented by the pointer’s value.
(a)
Given the following C++ code:
Thing *ptr = new Thing();
Thing *this = ptr;
delete ptr;
What is pointer this pointing to?
Don't know
the Thing() object
null
If a C or C++ programmer does not deallocate memory of variables no longer used, this generates ____ ____ _______ _________.
(a)
What type of problem will this C++ code generate?
while(true) {
Object o = new Object();
}
(a)
Given the following C++ code:
int arr[] = {2, 4, 6, 8};
int *ptr = arr;
Which element index is ptr at?
(a)
Given the following C++ code:
int arr[] = {2, 4, 6, 8};
int *ptr = arr;
What array reference is (ptr+2) equivalent to? What value can be dereferenced from ptr at this moment?
(a)
This object solves the dangling pointer issue by allowing pointers of dereferenced variables to point to itself, making unused pointers no longer dangling
(a)
This form of heap management is in every cell that stores the number of pointers currently pointing at that cell
(a)
This form of heap management initially marks all cells as garbage, then traces all available pointers to different cells, unmarking cells reachable by these pointers.
(a)
What type of heap management is shown by the picture?
(a)
A programming language is ________ _____ if type errors are always detected
(a)
If all type bindings are ______, nearly all type checking can be ______.
If type bindings are _______, type checking must be _______.
(a)
Java and C# have strong typing, except when ________ _______ types.
(a)
A (a) is a type whose variables may store different type values at different times during program execution.
Given the following C code in the picture,
what is the value of x? Hint: what type is x?
(a)
This is list comprehension in python:
[x * x for x in range(12) if x % 3 == 0]
What will be the resulting list?
(a)
True or False: The following list is valid in Python:
[1, 2.0, "three"]
(a)
An ___________ _____ is an unordered collection of data elements that are indexed by an equal number of values called ____.
(a)
In Perl, each hash element consists of two parts: a ___, which is a ______, and a _____, which is a ______ (number, string, or reference).
(a)
In this Perl associative array, "Perry" is a (a) .
In this Perl associative array, 55750 is a (a) .
An associative array is much ______ than an array if searches of the elements are required, because the implicit hashing operation used to access elements is very _________.
(a)
What would yourColor be if the following code was run in C++?
yourColor++;
blue
green
An error would occur
red
What would yourColor be if the following code was run in C++?
yourColor = 2;
blue
green
An error would occur
red
What would yourColor be if the following code was run in C++?
yourColor = (colors) 2;
blue
green
An error would occur
red
True or False: The values in this C# statement are equal.
int? x = 0;
int? y;
(a)
