Explain the features of Constants.
Advertisements
प्रश्न
Explain the features of Constants.
Explain the features of Constants in JAVA.
स्पष्ट कीजिए
Advertisements
उत्तर
- 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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
