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

Wha is the output from system.out.println(“hello”+null); ?

0 Answers  


What is the difference between state-based unit testing and interaction-based unit testing?

0 Answers  


What is a line break example?

0 Answers  


What is “try and catch” in java

5 Answers   Cap Gemini, TCS,


What is the symbol for average?

0 Answers  






Is java hard to learn?

0 Answers  


whats is the use of final,in which situation final can be used in the application?

2 Answers   DNS,


What do you mean by order of precedence and associativity?

0 Answers  


What is the independent variable in an experiment?

0 Answers  


What is the difference between math floor and math round?

0 Answers  


What are namespaces in java?

0 Answers  


Why is java not 100% pure oops?

0 Answers  


Categories