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 'Utility classe' - 3 question(s) found - Order By Rating | ||||
| ||||
Ans. Yes, With Java 8 we can use Interfaces as collection of utility methods through the use of default methods. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java 8  interfaces  utility class   utility classes | ||||
Related Questions | ||||
Differences between abstract class and interface ? | ||||
What are the different uses of Interfaces in Java ? | ||||
Why can't we have diamond problem with interfaces ? | ||||
Why do we need Thread class even in case we execute thread using runnable interface ? | ||||
What is the difference between List, Set and Map ? or What are the different Java Collections Interfaces ? | ||||
What are Marker Interfaces ? Name few Java marker interfaces ? | ||||
Can we declare interface methods as private ? | ||||
What is comparator interface used for ? | ||||
What is the use of runnable interface if we can always create a new thread using Thread class ? | ||||
Which of the following doesn't extend Collection interface ? | ||||
| ||||
Ans. It will throw the ParseException as the date format doesn't abide with the format of the specified date. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  date   utility classes   dateformat   exception   parseexception | ||||
Related Questions | ||||
What are the ways to avoid LazyInitializationException ? | ||||
How compiler handles the exceptions in overriding ? | ||||
What things should be kept in mind while creating your own exceptions in Java? | ||||
Difference between Checked and Unchecked exceptions ? | ||||
Explain java.lang.OutOfMemoryError ? | ||||
When do you get ClassCastException? or What is ClassCastException ? | ||||
If you are given a choice to implement the code to either Insert a Record or Update if already exist, Which approach will you follow ? | ||||
Explain throw, throws , try and catch in Java ? | ||||
What is ConcurrentModificationException ? | ||||
What will happen if we don't have termination statement in recursion ? | ||||
| ||||
Ans. It could be worthy to move a method to util class if the method needs to be shared, doesn't require polymorphic behavior and need not be overridden in special cases. Don't belong to one group through is-a relationship ( You can share through parent class method ) Don't implement a specific interface ( java 8 default methods ) Doesn't involve complex computing as you will be loosing the benefit of object state with just static method. Doesn't require polymorphic behavior as static methods don't participate in runtime polymorphism. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  utility classes   util classes   static methods   application design   rare | ||||
Related Questions | ||||
Name few Java util classes that were introduced with Java 7 ? | ||||
Name few Java Util classes introduced with Java 8 ? | ||||
What are Util Classes ? What are its advantages ? | ||||