Sunday, April 7, 2013

Concepts of Programming Languages - Chapter 5


Review Questions

2. What is the potential danger of case-sensitive names?
It affects the writability of a program because the need to remember specific case usage makes it more difficult to write correct programs.

3. In what way are reserved words better that keywords?
Reserved words are better that keywords because the ability to redefine keywords are confusing.

4. What is an alias?
Alias is a variable name that can be used to access the same memory loaction of another variable name.

6. What is the l-value of a variable? What is the r-value?
R-value is the address of a variable.
L-value is the variable's value.

7. Define binding and  binding time.
Binding is an association between an attribute and an entity.
Binding time is the time at which a binding takes place.

8. After language design and implementation [what are the four times binding can take place in a program?]
Type bindings, static type bindings, dynamic type bindings, storage bindings.

18. What is a block?
A block is a section of code which variables storage is allocated when the section is entered and deallocated when the section is exited.

23. What are the advantages of named constants?
To improve readability, to parameterize a program.


Problem Set

1. Decide which of the following identifier names is valid in C language. Support your decision.
_Student
Student
student123
In C language, underscore (_) and uppercase/lowercase letter are allowed to start identifier names, digits and symbols aren't allowed. "int" is a reserved word for integer so it's not allowed.


2. What is l-value? Write a statement in C language which gives the compile time error “l-value required”.
The address of a variable is called its l-value.
Example:
int i = 10, j;
j = 9--; //error C2105: '--' needs l-value


4. Why is the type declaration of a variable necessary? What is the value range of the int type variable in Java?
Because the type declaration of a variable determines the range of values the variable can store and the set of operations that are defined for values of the type.
-2147483648 to 2147483647.

5. Describe a situation each where static and dynamic type binding is required.
Static binding is required if we need the bindings to occur first before the run time begins and remains unchanged throughout program execution.
Dynamic binding is required if we need the binding to occur first during run time or can change in the course of program execution.

No comments:

Post a Comment