Monday, April 8, 2013

KBP - Chapter 5

Review Question

1. What are the design issues for names?
    - Are names case sensitive?
    - Are the special words of the language reserved words or keywords?

4. What is an alias?
   Alias is more than one variable name can be used to access the same memory location.

7. Define binding and bingding time.
   Binding is an association between an atribute and an entity, such as between a variable and its type or value, or between an operation and a symbol.
   Binding time is the time which a binding takes place is called.

9. Define static binding and dynamic binding.
   Static binding is a binding that first occurs before run time begins and remains unchanged throughout program execution.
   Dynamic binding is a binding that first occurs during run time or can change in the course of program execution.

13. Define lifetime, scope, static scope, and dynamic scope.
    Lifetime is the time during which the variable is bound to a specific memory location.
    Scope is the range of statements in which the variable is visible.
    Static scope is the method of binding names to nonlocal variables in ALGOL 60.
    Dynamic scope is the calling sequence of subprograms, not on their spatial relationship to each other.

18. What is a block?
    Block is a section of code.

___________________________________________________
Problem Set

1. Decide which of the following identifier names is valid in C language. Support your decision.
   
   _Student : valid.
   int : invalid. Because int is a data type, not an identifier.
   Student : valid.
   123Student : invalid. Because numbers can't be located at the front, can only located at the back after the identifier name.
   Student123 : valid.

4. Why is the type declaration of a variable necessary? What is the value range of the int type variable in Java?
    - Because it associates a type and an identifier with the variable, and allows the compiler to decide how musch storage space to allocate for storage of the value associated with the identifier.
    - Values range for int in Java : from -2,147,483,648 to 2,147,483,647.
    

5. Describe a situation each where static and dynamic type binding is required.
    - Static type binding : the binding to an object is optional, if a name is not bound to an object, the name is said to be null.
    - Dynamic type binding : every variable name is bound only to an object.

No comments:

Post a Comment