मराठी

Differentiate between the following: Constant and Variable

Advertisements

प्रश्न

Differentiate between the following:

Constant and Variable

फरक स्पष्ट करा
Advertisements

उत्तर

Constant

Variable

1. A constant is a value that cannot be changed during the execution of a program.

1. A variable is a named memory location whose value can be changed during the execution of a program.

2. A constant is declared using the final keyword in Java.

2. A variable is declared by specifying its data type and name.

3. Once a constant is assigned a value, it cannot be reassigned.

3. The value of a variable can be modified whenever required during program execution.

4. Constants are used to store fixed values that remain unchanged throughout the program.

4. Variables are used to store data values that may change during program execution.

5. Example: final int MAX = 100; Here, the value of MAX cannot be changed.

5. Example: int age = 18; Here, the value of age can be changed.

shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 6: Variables and Expressions - EXERCISE [पृष्ठ १३२]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
पाठ 6 Variables and Expressions
EXERCISE | Q 30. (a) | पृष्ठ १३२
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×