Exam 1z0-900 All QuestionsBrowse all questions from this exam
Question 36

Given the code fragment:

How long does this cookie persist?

    Correct Answer: D

    The code fragment creates a new cookie and sets its maximum age to -1 using the setMaxAge(-1) method. According to the Java Servlet API documentation, a max age of -1 indicates that the cookie should persist until the browser session ends, meaning it will be retained until the browser is shut down. Therefore, the cookie will last until the browser is closed.

Discussion
orjavaOption: D

Answer D