24. Give an example where you might use a static method


Static methods prove useful for creating utility classes, singleton classes and factory methods (Refer Q45, Q46 in Java section). Utility classes are not meant to be instantiated. Improper coding of utility classes can lead to procedural coding. java.lang.Math, java.util.Collections etc are examples of utility classes in Java.


No comments:

Post a Comment