How to define a constant variable in Java?



How to define a constant variable in Java?..

Answer / vidya bhushan dwivedi

The variable should be declared as static and final. So only one copy of the variable exists for all instances of the class and the value can't be changed also.

static final int MAX_LENGTH = 50; is an example for constant.

Is This Answer Correct ?    6 Yes 0 No

Post New Answer

More Core Java Interview Questions

How can we create a thread in java?

0 Answers  


Which sorting algorithm is in place?

0 Answers  


What is int lol?

0 Answers  


What is meant by class loader? How many types are there?

0 Answers  


What is final variable?

0 Answers  






where final and static variable stored?

3 Answers  


What is the collections api?

0 Answers  


What is treeset in java?

0 Answers  


What is multiple inheritance & can we implement it in java?

6 Answers   Satyam,


What is core java called?

0 Answers  


How do you compare objects in java?

0 Answers  


What is difference overloading and overriding?

0 Answers   Cyient,


Categories