chapter 6.

4 Apr

1. What is a descriptor?
an abstract indicator for accessing a file.

2. What are the advantages and disadvantages of decimal data types?
advantage: accuracy, used in daily life.
disadvantage: limited range, waste memory.

3. What are the design issues for character string types?
-Should strings be special type or primitive?
-Should strings have static or dynamic length?

4. Describe the three string length options.
A static length string, length is static and set when the string is created.
A limited dynamic length string, has a varying length up to a fixed maximum set by the variable’s definition.
A dynamic length string, has a varying length and no maximum.

6.What are the advantages of user-defined enumeration types?
high readability and reliability.(variable easily recognized, and has a determined range of value)

43. What is a compatible type?
it mean the value is still in range.

44. Define type error.
error when the value not inside of the type range.

45. Define strongly typed.
strrongly typed mean the compiler is not allowed to compile when there is type error detected.

46. Why is Java not strongly typed?
because mix typed statement are allowed.

48. What languages have no type coercions?
Ada, ML.

49. Why are C and C++ not strongly typed?
because mix typed statement are allowed.

50. What is name type equivalence?
Name equivalence means that the values have the same type as determined by the name of their type.

51. What is structure type equivalence?
Two data types are structurally equivalent if they have the same public members and define the same interface.

52. What is the primary advantage of name type equivalence?
it is easily implemented

53. What is the primary disadvantage to structure type equivalence?
difficult to implement.

2. How does a decimal value waste memory space?

1 sign bit
8 bits for the exponent
23 bits for the fraction.

7. What significant justification is there for the -> operator in C and C++?

for the sake of readability, and to picture / grasping at the concept of linked list.

1. What are the arguments for and against representing Boolean values as
single bits in memory?

for: boolean have true and false. if it false, then it is false. if it not false, it is true. it only need one bit to determine the value.
against: in fuzzy logic there’s no third and so on option.

21. In what way is static type checking better than dynamic type checking?

The advantages of static checking are that potential errors can be identified earlier, the program is better documented,
more care is needed in the program design and implementations can take advantage of
the additional information to produce more efficient programs with less runtime checking code.

22. Explain how coercion rules can weaken the beneficial effect of strong
typing?

because They decrease the type error detection ability of the compiler.

Advertisements

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: