What are the conventions regarding constant variables or static final variables ?
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Java - Interview Questions and Answers

 Q1. What are the conventions regarding constant variables or static final variables ?Core Java
admin
info@buggybread.com
Ans. They should be named all in upper case with underscore separating words.

Moreover the name should be such that it identifies the value. For example, if we are using constant for employee Id 123, it should be named something like EMPLOYEE_ID_123 and not EMPLOYEE_ID

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     constants   variable names   java conventions


Related Questions

  If I try to add Enum constants to a TreeSet, What sorting order will it use ?
  How do you define a class of constants in Java?
  Shall we keep the enumeration name in all capital letters as it contains all constants ?
  Why is a constant defined as a static final in Java?
  If we add Enum constants to a sorted collection ( Treemap , TreeSet ), What will be the order in which they will be maintained ?
 Can Enum be a replacement for a constant file in majority of the situation ?
 What is the advantage of using static final or constant variables in Java ?
 What will be result of following code and why

Integer int1 = 1;
Integer int2 = 1;
String str1 = new String("str");
String str2 = new String("str");
String str3 = "str";
String str4 = "str";

      
System.out.println(int1 == int2);
System.out.println(str1 == str2);
System.out.println(str3 == str4);
 If we have to maintain a value "7" denoting "number of days in a week" as constant variable, Which of the following is the best constant name and Why ?

SEVEN
NUMBER_OF_DAYS_IN_WEEK
NUMBER_OF_DAYS_IN_WEEK_7



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: