Selasa, 09 April 2013

Chapter 5

Review Questions


2.What is the potential danger of case-sensitive names?To some people , this is a serious detriment to readability, because names that look very similar in fact denote different entities. In that sense, case sensitivity violates the design principle that the language constructs that looks similar should have similar meanings. But in languages whose variable names are case sensitive, although Rose and rose look similar, there is  no connection between the.


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.


15.What is the general problem with static scoping?
-Allowing more access to both variables and subprograms than necessary
-The software used is highly dynamic, continually changes.



18. What is a block?A block is a section of code that allows to have its own local variables whose scope is    minimized and the variables are typically stack dynamic. Blocks provide the origin of the    phraseblock-structured language.

19.What is the purpose of the let constructs in functional languages?
A construct which first bind names to values, specified as expressions, and then uses the names defined in the first part.


23.  What are the advantages of normal constants?
A named constant allows for easier readability and writabillity, it’s also allows for easier error checking, where you only need to change the const variable in the program if it’s turns out to be wrong.


Problem Set

1. Decide which of the following identifier names is valid in C language. Support your decision
_Student -> valid, because it is started by a _. It is allowed in C.
int -> invalid, because it has the same name as one of a data type, hence might result in ambiguity.
Student -> valid, because it is started by an alphabet, regardless of the case.
123Student -> invalid, because identifier cannot have numbers as the start of the name.
Student123 -> valid, because although it contains numbers, the name starts with an alphabet.


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?
 The type declaration of a variable is necessary because, in a program it documented information about its data, which provides clues about the program’s behavior. The value range of the int type variable in Java is 32 bits (4 bytes).


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.


Tidak ada komentar:

Posting Komentar