Explain the features of Constants.
Advertisements
Questions
Explain the features of Constants.
Explain the features of Constants in JAVA.
Explain
Advertisements
Solution
- Fixed Value: A constant stores a value that cannot be changed once it is assigned.
- Declaration: Constants are declared using the
finalkeyword in Java. - Data Type: Every constant has a specific data type, such as
int,float,doubleorchar. - Initialisation: A constant must be assigned a value before it is used, and it can be assigned only once.
- Memory Allocation: Constants occupy memory according to their data types.
- Naming Convention: Constant names are generally written in uppercase letters, with underscores separating words.
- Program Reliability: Constants prevent accidental changes to fixed values, making programs more reliable and easier to maintain.
shaalaa.com
Is there an error in this question or solution?
