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.
|Core Java - Interview Questions and Answers for 'Variable names' - 1 question(s) found - Order By Newest|
|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|
|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 ?|