Computer Applications
What are symbolic constants? How are they useful in writing programs?
Answer
Memory locations whose values cannot be changed within a program are called constants or symbolic constants. The advantages of symbolic constants are:
- It improves the readability of the program and makes it easier for someone to understand the code.
- Any unintentional changes to such variables are flagged by the compiler.
- Later, if there is a change in the value of such variables (e.g. interest rate changed), you just need to modify its value at one place and all the other occurrences will be taken care of automatically.
Related Questions
Write a Java constant declaration that gives the name TAX_RATE to the value 15%.
If you want to change the precedence of operations in an expression, which symbols do you use?
What is the output produced by the following lines of program code?
char x, y; x = 'y'; System.out.println(x); y = 'z'; System.out.println(y); x = y; System.out.println(x);
How can you write single line comments in Java?