Concepts of Programming Languages - Chapter 5 (Names, Bindings, and Scopes)

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

4. What is an alias?

Aliases are the variables when more than one variable name can be used to access the same memory location.

3. In what way are reserved words better than keywords?

As a language design choice, reserved words are better than keywords because the ability to redefine keywords can be confusing. or Reserved words are better than keywords in a language design choice, since its ability to redefine keywords can be confusing.

7. Define binding and binding time.

Binding is an association between an attribute and an entity, such as between a variable and its type or value, or between a variable and its type or value, or between an operation and a symbol. Binding time is the time at which a binding takes place.

5. Which category of C++ reference variables is always aliases?

Category of C++ reference variables is always aliases when a C++ pointer is set to point at a named variable, the pointer, when dereferenced.

18. What is a block?

Many languages allow new static scopes to be defined in the midst of executable code. This powerful concept, allows a section of code to have its own local variables whose scope is minimized. A section of code is called a block.

5. Describe a situation each where static and dynamic binding type is required.

Static binding: A class with multiple methods that have the same name, but with different parameter lists, requires static binding to call these methods. Dynamic binding: In case of inheritance, if both the base class and the derived class have methods of the same name with the same parameter list and return type, dynamic binding would be used to call these methods.

1. What are the design issues for names?

The following are the primary design issues for names: - Are names case sensitive? - Are the special words of the language reserved words or keywords?

4. Why is the type declaration of a variable necessary? What is the value range of the int type variable in Java?

The type 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. The int type in Java have a value range of -2147483648 to 2147483647. or The type declaration of a variable is necessary because the type of a variable determines the range of values the variable can store and the set of operations that are defined for values for the type.

2. What is the potential danger of case-sensitive names?

To some people, the problems are about writability and readability. For readability, because names that look very similar in fact denote different entities. For writability, many of the predefined names including both uppercase and lowercase letters.

1. Decide which of the following indentifier names is valid in C language. Support your decision.

_student // valid. int // not valid, because int is a keyword for integer used in variable declaration. Student // valid. 123Student // not valid, because variable doesn't start with number. Student123 // valid.

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.

int i = 10, j; j = i+++++i; // this statement will give compile time error—" l-value required" or #include <stdio.h> int main(){ int a; 2 = a; }

6. What is the l-value of a variable? What is the r-value?

l-value of a variable is the address of a variable, while r-value of a variable is a variable's value itself.


Kaugnay na mga set ng pag-aaral

Ch 26 Nursing Care and Discharge Teaching

View Set

Ch. 5 Chronic Illness and Older Adults

View Set

Gingival and Dentogingival Junctional Tissue

View Set

Law for Business 2301 Chapter 6,7, 8,10, 11, and 13

View Set

Psychology Chapter 8 Study Guide

View Set

Go Math Grade 4 Chapters 6-8 Vocabulary Words

View Set

RFINANCE10: Defaults and Forclosure

View Set