Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests -

Advance Java MCQs

James Gosling developed JAVA in May 1995 at Sun Microsystems. The primary purpose of the JAVA of programming language is to let programmers write once, run anywhere (WORA). This means that compiled Java code can run without recompilation on any platform that supports Java.

Solve Multiple-choice Questions on Advance Java

To prepare better for the GATE Exam, it is very beneficial to solve MCQs before exams for multiple reasons. You can practise, analyse and understand concepts while solving them. It will also help you in strengthening your time management.

Advance Java MCQs are a prerequisite to the current examination pattern. If you wish to learn more about GATE MCQs, you can check notes, mock tests, and previous years’ question papers. Get an idea about Advance Java MCQs by solving the ones compiled below for your practice.

Multiple-choice Questions on Advance Java

1. Which of the following is used for session migration?

  1. Persisting the session in database
  2. URL rewriting
  3. Creating new database connection
  4. Kill session from multiple sessions

Answer (a)

2. Which of the below is not a session tracking method?

  1. URL rewriting
  2. History
  3. Cookies
  4. SSL sessions

Answer (b)

3. Which of the following is stored at the client side?

  1. URL rewriting
  2. Hidden form fields
  3. SSL sessions
  4. Cookies

Answer (d)

4. Which of the following leads to high network traffic?

  1. URL rewriting
  2. Hidden form fields
  3. SSL sessions
  4. Cookies

Answer (a)

5. Which of the following is not true about session?

  1. All users connect to the same session
  2. All users have the same session variable
  3. Default timeout value for session variable is 20 minutes
  4. New session cannot be created for a new user

Answer (c)

6. What is the maximum size of cookie?

  1. 4 KB
  2. 4 MB
  3. 4 bytes
  4. 40 KB

Answer (a)

7. How can we invalidate a session?

  1. session.discontinue()
  2. session.invalidate()
  3. session.disconnect()
  4. session.falsify()

Answer (b)

8. Which method creates unique fields in the HTML, which are not shown to the user?

  1. User authentication
  2. URL writing
  3. HTML Hidden field
  4. HTML invisible field

Answer (c)

9. Which object is used by spring for authentication?

  1. ContextHolder
  2. SecurityHolder
  3. AnonymousHolder
  4. SecurityContextHolder

Answer (d)

10. Which page directive should be used in JSP to generate a PDF page?

  1. contentType
  2. generatePdf
  3. typePDF
  4. contentPDF

Answer (a)

11. Which tag should be used to pass information from JSP to included JSP?

  1. Using <%jsp:page> tag
  2. Using <%jsp:param> tag
  3. Using <%jsp:import> tag
  4. Using <%jsp:useBean> tag

Answer (a)

12. Application is an instance of which class?

  1. javax.servlet.Application
  2. javax.servlet.HttpContext
  3. javax.servlet.Context
  4. javax.servlet.ServletContext

Answer (d)

13. Which option is true about session scope?

  1. Objects are accessible only from the page in which they are created
  2. Objects are accessible only from the pages which are in the same session
  3. Objects are accessible only from the pages which are processing the same request
  4. Objects are accessible only from the pages which reside in the same application

Answer (b)

14. Which one is the correct order of phases in the JSP life cycle?

  1. Initialization, Cleanup, Compilation, Execution
  2. Initialization, Compilation, Cleanup, Execution
  3. Compilation, Initialization, Execution, Cleanup
  4. Cleanup, Compilation, Initialization, Execution

Answer (c)

15. “request” is an instance of which one of the following classes?

  1. Request
  2. HttpRequest
  3. HttpServletRequest
  4. ServletRequest

Answer (c)

16. Which is not a directive?

  1. include
  2. page
  3. export
  4. useBean

Answer (c)

17. Which is mandatory in <jsp:useBean /> tag?

  1. id, class
  2. id, type
  3. type, property
  4. type,id

Answer (a)

18. Which one of the following is correct for directive in JSP?

  1. <%@directive%>
  2. <%!directive%>
  3. <%directive%>
  4. <%=directive%>

Answer (a)

19. Which of the following action variables is used to include a file in JSP?

  1. jsp:setProperty
  2. jsp:getProperty
  3. jsp:include
  4. jsp:plugin

Answer (c)

20. Which attribute uniquely identifies an element?

  1. ID
  2. Class
  3. Name
  4. Scope

Answer (a)

21. “out” is the implicit object of which class?

  1. javax.servlet.jsp.PrintWriter
  2. javax.servlet.jsp.SessionWriter
  3. javax.servlet.jsp.SessionPrinter
  4. javax.servlet.jsp.JspWriter

Answer (d)

22. Which object stores references to the request and response objects?

  1. sessionContext
  2. pageContext
  3. HttpSession
  4. sessionAttribute

Answer (b)

23. What temporarily redirects response to the browser?

  1. <jsp:forward>
  2. <%@directive%>
  3. response.sendRedirect(URL)
  4. response.setRedirect(URL)

Answer (c)

24. Which tag is used to set a value of a JavaBean?

  1. <c:set>
  2. <c:param>
  3. <c:choose>
  4. <c:forward>

Answer (a)

25. Java code is embedded under which tag in JSP?

  1. Declaration
  2. Scriptlet
  3. Expression
  4. Comment

Answer (b)

Also Explore,

Comments

Leave a Comment

Your Mobile number and Email id will not be published.

*

*