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

does java support pointers?

0 Answers  


How would you format a date in java? I.e. In the ddmmyyy format?

0 Answers  


What is charat java?

0 Answers  


What are keywords and reserved words in java?

0 Answers  


What is a copy constructor in java?

0 Answers   Amazon,






Considering notepad/ie or any other thing as process, what will happen if you start notepad or ie 3 times? Where 3 processes are started or 3 threads are started?

0 Answers  


why did you choose your career in IT?

1 Answers   LIC,


What is difference between == equals () and compareto () method?

0 Answers  


What is the purpose of the enableevents() method?

0 Answers  


What are the advantages of arraylist over arrays?

0 Answers  


What is this keyword used for?

0 Answers  


What is the function of java?

0 Answers  


Categories