Multiple choice technology web technology

Given the deployment descriptor for a Web Application is

  1. The Servlet will output 'javabeat null' in the Server Console.

  2. The Servlet will fail to load as the init param property 'no-name' is not mentioned in the deployment descriptor

  3. A NullPointerException will be raised as calling getServletConfig() in the init() method will return a null reference.

  4. The Servlet will output 'javabeat ' in the Server Console.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The getServletConfig().getInitParameter('no-name') call will return null when the parameter is not defined in web.xml, but this does not cause an exception - the servlet will load successfully and output 'javabeat null'. The init() method can safely call getServletConfig() and getInitParameter() returns null for missing parameters rather than throwing NullPointerException.