Search Interview Questions  3348 questions in repository. There are more than 200 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. 

 
Java  Interview Questions and Answers  
_{}
 
Ans. NUMBER_OF_DAYS_IN_WEEK Constant should be such that it uniquely identifies the value it holds and context of the value. SEVEN uniquely identifies the value but doesn't express the context. Though NUMBER_OF_DAYS_IN_WEEK and NUMBER_OF_DAYS_IN_WEEK_7 makes sense in terms of unique value identification and context but 7 at the end of constant name appears useless as all weeks have 7 days and hence it's the only value it can hold. If it would have been "number of days in a month", it would have made sense to include number of days at the end like NUMBER_OF_DAYS_IN_MONTH_30 NUMBER_OF_DAYS_IN_MONTH_31 NUMBER_OF_DAYS_IN_MONTH_27 NUMBER_OF_DAYS_IN_MONTH_28  
Help us improve. Please let us know the company, where you were asked this question :  
_{ Like Discuss Correct / Improve constant variables static final variable java conventions java naming conventionsCorrectionDuplicate of Another QuestionCompany where this question was AskedSuggestion}  
Related Questions  
What are the conventions regarding constant variables or static final variables ?  
What is the advantage of using static final or constant variables in Java ?  
If we have to maintain a value "31" denoting "number of days in a month" as constant variable, Which of the following is the best constant name and Why ? THIRTY_ONE NUMBER_OF_DAYS_IN_MONTH NUMBER_OF_DAYS_IN_MONTH_31  
Would you consider creating a constant name for "null" ?  
How do we define constant variables in Java ?  