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?
- Persisting the session in database
- URL rewriting
- Creating new database connection
- Kill session from multiple sessions
Answer (a)
2. Which of the below is not a session tracking method?
- URL rewriting
- History
- Cookies
- SSL sessions
Answer (b)
3. Which of the following is stored at the client side?
- URL rewriting
- Hidden form fields
- SSL sessions
- Cookies
Answer (d)
4. Which of the following leads to high network traffic?
- URL rewriting
- Hidden form fields
- SSL sessions
- Cookies
Answer (a)
5. Which of the following is not true about session?
- All users connect to the same session
- All users have the same session variable
- Default timeout value for session variable is 20 minutes
- New session cannot be created for a new user
Answer (c)
6. What is the maximum size of cookie?
- 4 KB
- 4 MB
- 4 bytes
- 40 KB
Answer (a)
7. How can we invalidate a session?
- session.discontinue()
- session.invalidate()
- session.disconnect()
- session.falsify()
Answer (b)
8. Which method creates unique fields in the HTML, which are not shown to the user?
- User authentication
- URL writing
- HTML Hidden field
- HTML invisible field
Answer (c)
9. Which object is used by spring for authentication?
- ContextHolder
- SecurityHolder
- AnonymousHolder
- SecurityContextHolder
Answer (d)
10. Which page directive should be used in JSP to generate a PDF page?
- contentType
- generatePdf
- typePDF
- contentPDF
Answer (a)
11. Which tag should be used to pass information from JSP to included JSP?
- Using <%jsp:page> tag
- Using <%jsp:param> tag
- Using <%jsp:import> tag
- Using <%jsp:useBean> tag
Answer (a)
12. Application is an instance of which class?
- javax.servlet.Application
- javax.servlet.HttpContext
- javax.servlet.Context
- javax.servlet.ServletContext
Answer (d)
13. Which option is true about session scope?
- Objects are accessible only from the page in which they are created
- Objects are accessible only from the pages which are in the same session
- Objects are accessible only from the pages which are processing the same request
- 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?
- Initialization, Cleanup, Compilation, Execution
- Initialization, Compilation, Cleanup, Execution
- Compilation, Initialization, Execution, Cleanup
- Cleanup, Compilation, Initialization, Execution
Answer (c)
15. “request” is an instance of which one of the following classes?
- Request
- HttpRequest
- HttpServletRequest
- ServletRequest
Answer (c)
16. Which is not a directive?
- include
- page
- export
- useBean
Answer (c)
17. Which is mandatory in <jsp:useBean /> tag?
- id, class
- id, type
- type, property
- type,id
Answer (a)
18. Which one of the following is correct for directive in JSP?
- <%@directive%>
- <%!directive%>
- <%directive%>
- <%=directive%>
Answer (a)
19. Which of the following action variables is used to include a file in JSP?
- jsp:setProperty
- jsp:getProperty
- jsp:include
- jsp:plugin
Answer (c)
20. Which attribute uniquely identifies an element?
- ID
- Class
- Name
- Scope
Answer (a)
21. “out” is the implicit object of which class?
- javax.servlet.jsp.PrintWriter
- javax.servlet.jsp.SessionWriter
- javax.servlet.jsp.SessionPrinter
- javax.servlet.jsp.JspWriter
Answer (d)
22. Which object stores references to the request and response objects?
- sessionContext
- pageContext
- HttpSession
- sessionAttribute
Answer (b)
23. What temporarily redirects response to the browser?
- <jsp:forward>
- <%@directive%>
- response.sendRedirect(URL)
- response.setRedirect(URL)
Answer (c)
24. Which tag is used to set a value of a JavaBean?
- <c:set>
- <c:param>
- <c:choose>
- <c:forward>
Answer (a)
25. Java code is embedded under which tag in JSP?
- Declaration
- Scriptlet
- Expression
- Comment
Answer (b)
Also Explore,
Comments