ADVANCED TOPICS IN COMPILER DESIGN
CODE GENERATION FOR OBJECT ORIENTED LANGUAGES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
To make the program easier for clients to use
|
|
To make the program easier for programmers to maintain
|
|
To make the program execute in less time
|
|
To make the program use less memory
|
Detailed explanation-1: -If it’s hardcoded everywhere in the application, it has to be replaced everywhere, which is a waste of time. With a constant as in your example, you just have to replace it at one place and then it’s replaced everywhere.
Detailed explanation-2: -The name of a named constant is therefore indicative of the value’s role. A further advantage of using named constants is that should the given value be modified in the source code, it is sufficient to modify the declaration statement, instead of looking up all the occurrences of the value.
Detailed explanation-3: -Advantages of using constants Declaring a constant means that you can use the same identifier throughout a program, for example, the name TAX to represent a tax rate instead of the value 0.2 (for 20%). This keeps the program code consistent, which makes it easier to read and debug a program.
Detailed explanation-4: -It makes code more readable. It saves work when you make a change. You avoid risky errors. More items