Multiple choice technology web technology

Imagine that you want to set the inactive time for a particular servlet to 10 minutes. Which of the following is the preferred way to do it?

  1. HttpSession.setMinInactiveInterval(10);

  2. HttpSession.setMinInactiveInterval(10 * 60);

  3. HttpSession.setMaxInactiveInterval(10 * 60);

  4. HttpSession.setMaxInactiveInterval(10);

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

The setMaxInactiveInterval method accepts seconds as the parameter, not minutes. To set 10 minutes, you need to convert to seconds (10 * 60 = 600). Options A and B use setMinInactiveInterval which doesn't exist. Option D only sets 10 seconds, not 10 minutes.