HW05

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What are some advantages that dynamic typing offers over static typing? A. reliability B. flexibility C. efficiency D. writability

B. flexibility D. writability

How would would describe the type binding in this Perl statement? Assume this is the first reference to $var. $var = 5; A. $var is dynamically bound to type integer B. $var is statically bound to type scalar C. both A & B

C. both A & B: - $var is dynamically bound to type integer - $var is statically bound to type scalar

Select the true statement. A. A binding is static if it first occurs before run time and remains unchanged throughout program execution. B. A binding is dynamic if it first occurs during execution or can change during execution of the program. C. both A & B.

C. both A & B: - A binding is static if it first occurs before run time and remains unchanged throughout program execution. - A binding is dynamic if it first occurs during execution or can change during execution of the program.

Downcasting a derived type to a base type in C++ is A. explicit only B. implicit C. never allowed

implicit

Which of the following do named constants support? A. readability B. parameterization C. both A & B

readability & parameterization

Ada was designed by the Dept of Defense for: A. reliability B. large team projects C. embedded systems D. concurrent programming

reliability large team projects embedded systems concurrent programming

What does the RE in this Perl statement match? next if /^$/; A. any line B. a blank line

- a blank line

What can occur in a dynamically scoped language that cannot occur in a statically scoped language? A. a reference to a non-local variable can be bound to a memory address at runtime B. the visibility of a non-local variable can change at runtime C. the address of a global variable can be bound by the compiler D. the scope and visibility of a variable can be determined by looking at the code

- a reference to a non-local variable can be bound to a memory address at runtime - the visibility of a non-local variable can change at runtime

Which of the following is not a category of variables defined by storage binding? A. stack dynamic B. explicit stack dynamic C. static D. implicit heap dynamic

- explicit stack dynamic

What will this Perl statement achieve? (s is the substitute command and g will apply the command to all instances of the match in the line) $line =~ s/^[0-9]*\.//g; A. remove all digits in the line. B. remove all the digits at the beginning of the line. C. remove all the digits at the beginning of the line that are followed by .

- remove all the digits at the beginning of the line that are followed by.

The following Perl statements will execute without error. What can you thus conclude? $var = 5; $var = "hello there"; A. strings are primitive scalar types B. strings are implicitly coerced into integers C. Perl is a dynamically-typed language D. memory for $var is dynamically allocated

- strings are primitive scalar types - Perl is a dynamically-typed language - memory for $var is dynamically allocated

What is true about this C code if it comprises one compilation unit? void funa( ) { extern x; x = x--; printf("x = %d",x); } A. the linker will bind x to a memory address on the runtime stack B. the linker will bind x to a memory address in the data section C. the compiler will bind x to a memory address in the data section

- the linker will bind x to a memory address in the data section

What is true in the assignment statement 'A = 5 + 8'? A. there is no rvalue B. the result of 5 + 8 is an unmodifiable value C. the rvalue is not bound to a memory address D. the lvalue must be modifiable.

- the result of 5 + 8 is an unmodifiable value - the rvalue is not bound to a memory address - the lvalue must be modifiable

What is true concerning C static variables, such as x in this C function? void fun () { static int x = 5; } A. the value of x can never change B. x is bound to the same memory address throughout program execution C. x is bound to a memory address by the compiler D. there can be only one instance of a variable named 'x' in the program.

- x is bound to the same memory address throughout program execution - x is bound to a memory address by the compiler

What does this C function achieve? void ptrs(int** ptr1, int** ptr2){ int* tmp_ptr = *ptr1; *ptr1 = *ptr2; *ptr2 = tmp_ptr; } A. you are swapping integer values B. you are swapping addresses to integers C. you are swapping addresses to pointers

- you are swapping addresses to integers

Under what condition is language B less strongly typed than language A? A. if B has more implicit type coercions than A B. if B has more explicit type conversions than A C. both statements are true

A. if B has more implicit type coercions than A

The regular expressions (REs) that follow use this notation: [ ] denotes a set of choices for a single character ( ) is a substring * is 0 or more + is 1 or more { } is optional . (dot) is a wildcard for a single character ^ anchors to the beginning of the line $ anchors to the end of the line \ is used to escape a metacharacter (True/False) An Ada identifier must start with a letter and be followed by zero or more letters, digits or underscores. An underscore cannot be the final symbol or be followed by another underscore. Is this regular express correct? [a-zA-Z][a-zA-Z0-9_]([a-zA-Z0-9])*{_[a-zA-Z0-9]}

False

(True/False) This Ada program will raise a range error exception at runtime. PROCEDURE main is subtype SUB_INT is INTEGER range 1..50; X : SUB_INT; BEGIN X := 60; END

True

(True/False) A static variable with class scope in C++ exists before any object of that class is created.

True

(True/False) It is possible to dynamically bind the value of a variable and statically bind the address of that same variable.

True

(True/False) The statement below is an acceptable initialization for a static named constant of type char[]. const char myName[30] = "santa claus";

True

What is this Ada statement? type AN_ARRAY is array(FIRST..LAST) of INTEGERS; A. an abstract data type B. an array variable of integers named AN_ARRAY C. both A and B

an abstract data type

Which is always bound to a modifiable memory reference? A. an lvalue B. an rvalue C. both must be bound

an lvalue

The scripting languages JavaScript, Python, PHP, and Ruby are A. dynamically typed B. typeless C. statically typed D. a combination

dynamically typed


Kaugnay na mga set ng pag-aaral

Unit 7 History Short Answer Study Guide

View Set

Chapter 43 Ethics and Values (Study the section on Professional guidelines [Nursing Code of Ethics] & Ethical issues in healthcare] ▪️highlighted asterisks ▪️

View Set

Project Management quiz questions Ch 7

View Set

NWCC Mr. Miller: Engine Repair SG

View Set