1.

What should the return type of method where there is no return value?(a) Null(b) Empty collection(c) Singleton collection(d) Empty StringI have been asked this question in quiz.I'm obligated to ask this question of Coding best practices topic in chapter Autoboxing & Miscellaneous of Java

Answer»

Right OPTION is (b) EMPTY COLLECTION

Explanation: Returning Empty collection is a GOOD practice. It eliminates chances of UNHANDLED null pointer exceptions.



Discussion

No Comment Found

Related InterviewSolutions