CS301 Final

Ace your homework & exams now with Quizwiz!

Design issues for an array are?

1. What types are legal for subscripts. 2. When does array allocation take place. 3. Can arrays be initialized when they have their storage allocated? 4. what kind of slices are allowed if any? 5. When are subscript ranges bound

What is a compatible type?

A compatible type is one that either is legal for the operator or is allowed under language rules to be implicitly converted by compiler-generated code (or the interpreter) to a legal type.

Define strongly typed

A programming language is strongly typed if type errors are always detected.

What is the r-value of a variable?

A variable's value is sometimes called its r-value because it is what is required when the name of the variable appears in the right side of an assignment statement.

What is the primary reason why all Java objects have a common ancestor?

All Java objects can all inherit a few universally useful methods.

Why are C and C++ not strongly typed?

C and C++ are not strongly typed languages because both include union types, which are not type checked.

Describe a situation in which the add operator in a programming language would not be associative.

Consider the integer expression A + B + C . Suppose the values of A, B, and C are 20,000, 25,000, and -20,000, respectively. Further suppose that the machine has a maximum integer value of 32,767. If the first addition is computed first, it will result in overflow. If the second addition is done first, the whole expression can be correctly computed.

Define dynamic binding

Dynamic binding (or late binding or virtual binding) is name binding performed as the program is running

Define Dynamic scoping

Dynamic scoping is based on the calling sequence of subprograms, not on their spatial relationship to each other. Thus, the scope can be determined only at run time.

In what way is static type checking better than dynamic type checking?

First, anything done at compile time leads to better overall efficiency.Second, type checking uncovers program errors, and the earlier errors are found the less costly it is to remove them.

What exactly does it mean for a subclass to have an is-a relationship with its parent class?

If a subclass has an is-a relationship with its parent class, a variable of the subclass can appear anywhere a variable of the parent class is allowed to appear

Simple when might the add operation not be associative

If it results in an overflow

What is name type equivalence

Name type equivalence means that two variables have equivalent types if they are defined either in the same declaration or in declarations that use the same type name.

Describe how a multiple-processor machine could be used to implement resolution. Could Prolog use this method?

On a single processor machine, the resolution process takes place on the rule base, one rule at a time, starting with the first rule, and progressing toward the last until a match is found. Because the process on each rule is independent of the process on the other rules, separate processors could concurrently operate on separate rules. When any of the processors finds a match, all resolution processing could terminate. Yes prolog could.

Explain one disadvantage of inheritance.

One disadvantage of inheritance is that types cannot be defined to be independent.

What are the arguments (pro and con) both for and against the exclusive use of Boolean expressions in the control statements in Java (as opposed to also allowing arithmetic expressions as in C and C++)?

Pro: reliability that results from disallowing a wide range of types for this use. con:typing errors that result in references to variables of incorrect types are not detected by the compiler as errors.

What are the pros and cons for Python's use of indentation to specify compound statements in control statement?

Pro:it demands that programmers use an indentation scheme that promotes readability. This results is a rigid standard for program layout that ensures that all Python programs will be equally readable Con: It is difficult to find a strong argument against the use of indentation to indicate program structure, although sloppy programmers will find the required discipline annoying.

Define static binding

Static binding (or early binding) is name binding performed before the program is run.

What is structure type equivalence?

Structure type equivalence means that two variables have equivalent types if their types have identical structures.

When might you want the compiler to ignore type differences in an expression?

Suppose Type1 is a subrange of Integer. It may be useful for the difference between Type1 and Integer to be ignored by the compiler in an expression.

What is the l value of a variable?

The address of a variable is called it's l-value because the address is what is required when the name of a variable appears in the left side of an assignment.

Some programming languages are type-less. What are the obvious advantages and disadvantages of having no types in a language

The advantage of a type-less language is flexibility; any variable can be used for any type values. The disadvantage is poor reliability due to the ease with which type errors can be made, coupled with the impossibility of type checking detecting them.

What is the referencing environment of a statement?

The referencing environment of a statement is the collection of all variables that are visible in the statement.

What are the pros and cons of using unique closing reserved words on compound statements?

Unique closing keywords on compound statements have the advantage of readability and the disadvantage of complicating the language by increasing the number of keywords.

Define static scope

Variable may only be called (referenced) from within the block of code in which it is defined. The scope is determined when the code is compiled.

How does a decimal value waste memory space?

it takes four binary bits to store a single decimal digit, but those four bits are capable of storing 16 different values. Therefore, the ability to store six out of every 16 possible values is wasted.


Related study sets

***HURST REVIEW NCLEX-RN Readiness Exam 1***, Hurst Practice Exam 2, Hurst Review Test # 3, Hurst Review Test #2, Hurst Readiness Exam 3, Hurst (Readiness Exam #4), Hurst (Readiness Exam #3), Hurst 1, HESI 8, HESI 7, HESI Exit 2 leigh_love_life

View Set

Chapter 5: Carbohydrates- Sugars, Starches, and Fiber

View Set

Chapter 11 Anatomy and Physiology I

View Set

"The Black Cat" by Edgar Allan Poe Plot Summary

View Set

UNIT 4: Interest Rates, TVM, and Risk and Return Quiz

View Set

5-Sickle Cell Anemia (Lecture + Syllabus)

View Set