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 'Enums' - 22 question(s) found - Order By Newest | ||||
| ||||
Ans. Generics , Enums , Autoboxing , Annotations and Static Import. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   java5   generics   enum   autoboxing   annotations   static import   rare | ||||
Try 1 Question(s) Test | ||||
| ||||
Ans. final | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   enum | ||||
| ||||
Ans. Tree Set will sort the Values in the order in which Enum constants are declared. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   collections   set   treeset   enum   sorting   technical lead | ||||
| ||||
Ans. No. compareTo method is declared final for the Enumerations and hence cannot be overriden. This has been intentionally done so that one cannot temper with the sorting order on the Enumeration which is the order in which Enum constants are declared. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   compareto   final methods   enum   enumeration expert | ||||
| ||||
Ans. static | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   enum | ||||
| ||||
Ans. Enums were introduced with java 5. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java5   enum | ||||
Try 1 Question(s) Test | ||||
| ||||
Ans. An enum type is a special data type that enables for a variable to be a set of predefined constants | ||||
Sample Code for enum | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   java5   enum   basic interview question basic   frequent | ||||
Try 2 Question(s) Test | ||||
| ||||
Ans. WEDNESDAY FRIDAY SATURDAY Only one FRIDAY will be printed as Set doesn't allow duplicates.Elements will be printed in the order in which constants are declared in the Enum. TreeSet maintains the elements in the ascending order which is identified by the defined compareTo method. compareTo method in Enum has been defined such that the constant declared later are greater than the constants declared prior. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   code   coding   enum   set   treeset   advanced | ||||
Try 3 Question(s) Test | ||||
| ||||
Ans. An enumeration is an interface containing methods for accessing the underlying data structure from which the enumeration is obtained. It allows sequential access to all the elements stored in the collection. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   enum   enumeration interface   basic interview question | ||||
Try 2 Question(s) Test | ||||
Ans. SUNDAY MONDAY SATURDAY | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  enum   set   collections   hashset   coding   code | ||||
Try 3 Question(s) Test | ||||
Ans. FRIDAY , SATURDAY and WEDNESDAY will be printed but the order cannot be determined. Only one FRIDAY will be printed as Set doesn't allow duplicates. Order cannot be determined as HashSet doesn't maintain elements in a particular order. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   code   coding   enum   set   hashset | ||||
Try 3 Question(s) Test | ||||
| ||||
Ans. No. Enums are final by design. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   enums   inheritance  object oriented programming (oops)  oops concepts   yes-no Asked in 1 Companies intermediate | ||||
| ||||
Ans. Enum is actually a class with pre defined constants. So enum name should follow the convention of the Class name. Though the constant names or the Enum variables should follow the convention of having all capital letters. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   enum   enumerations   java conventions   java naming conventions | ||||
| ||||
Ans. Yes, with Enum as was getting an exception while doing equality check for enum field. got it fixed by adding @Enumerated(EnumType.STRING) to the field in entity. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   hibernate criteria   enumerations | ||||
| ||||
Ans. http://www.buggybread.com/2015/01/java-enum-classes-and-interfaces.html | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   enums | ||||
Ans. Order in which constants are declared. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  enum   collections   sorted collections   treemap   treeset   compareto   comparable   java | ||||
| ||||
Ans. Yes , it can be but it may not be an optimal alternative if we need to change the values frequently. As Enum is compiled like any Java File , any change requires the application to be rebuild , deployed and restart. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  enum  design | ||||
| ||||
Ans. Enumeration can iterate only legacy collections like Vector , HashTable and Stack whereas Iterator can iterate both legacy and non legacy collections. Enumeration is less safer than Iterator Enumeration is fail safe whereas Iterator is fail fast Iterator allows for removal of element while traversal whereas Enumeration doesn't have remove method. Enumerations were introduced in Java 1 whereas Iterators were introduced with Java 2 Enumerations have methods like hasMoreElements and nextElement whereas Iterators have methods like hasNext, next and remove | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  enumeration vs iterator  collections Basic   frequent | ||||
| ||||
Ans. No | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  enum | ||||
| ||||
Ans. Yes | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  enum  enum within enum | ||||
| ||||
Ans. Enums in Java is a facility to have objects upfront and use them as constants. Even if such a facility is not available , a workaround could be achieved. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  enum | ||||
| ||||
This question is still unanswered. Can you please provide an answer. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  enum typescript  enum javascript | ||||