What is the best way to handle the null pointer exceptions? Null is a common enemy to all the developers…