livingmylivetothefullest

It's about life

Chapter 5

Names, Bindings, and Scopes

Assignment from Tri Djoko Wahjono

Review Questions

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

2. What is the potential danger of case-sensitive names ?
Because case sensitivity violates the design principle that language constructs that look similar should have similar meanings

4. What is an alias ?
Alias is more than one variable name that accesses the same memory location

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

8. After language design and implementation [what are the four times bindings can take place in a program ? ]
Compile time, load time , link time and run time

9. Define static binding and dynamic binding
Static binding is done at compile time when a function is called in order to match it with the definition, while Dynamic binding is at run time where we can specify that the compiler matches a function call with the correct function definition at run time.

18. What is a block ?
A block is a section of code that has its own local variable whose scope is minimized. The variables are typically stack dynamic, so their storage is allocated when the section is entered and deallocated when the section is exited.

19. What is the purpose of the let constructs in functional languages ?
A let construct is a call to the function LET.

Problem Set
1. Decide which of the following identifier names is valid in C language. Support your decision.
_Student = valid, it starts with an underline and it is allowed.
Int = invalid. It is a reserved name for integer data type.
Student = valid. It uses capital letter which is allowed.
123Student=invalid. Variable names in C cannot be started with numbers.
Student123=valid. Variable in C can contain numbers as long it is not on the front.

2.What is l-value ? Write a statement in C language which gives the compile time error “l-value required”
L-value is memory address that are programmatically accessible to the running program.
printf(“%s\n”,*words++);

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 / name with the variable. Tyhe type allows the compiler to interpret statements correctly. For example, instruction in the CPU for adding two integers is different from the instruction of adding two float values. Hence, the compiler must know the type of the variables so it can generate the correct add instructions.The range of Java Int is -2,147,483,648 to 2,147,483,647

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on April 8, 2013 by and tagged .
April 2013
M T W T F S S
« Mar   Jun »
1234567
891011121314
15161718192021
22232425262728
2930  

Blog Stats

  • 6,909 hits
%d bloggers like this: