Upload
neelesh-tanwar
View
27
Download
2
Embed Size (px)
DESCRIPTION
sdfds
Citation preview
Sl No
Question Choice A Choice B Choice C Choice D Choice E
1 JSP is an acronym for ? Java Script Pages Java Servlet Pages ans) Java Server Pages None of the Above
2 Which of these is correct? JSP technically can do anything servlets can't do
ans) JSP technically can't do anything servlets can't do
JSP technically can do anything HTML can’t do
JSP technically can’t do anything HTML can do
3 How do I put an image in a JSP page?
send an <IMAGE …> tag to the client
send an <IMAGES …> tag to the client
ans) send an <IMG …> tag to the client
None of the above
4 At Page translation time.? Servlet code gets executed ans) JSP constructs get translated to Servlet code
Interpretation of JSP code occurs
None of the above
5 What happens at Request time?.
Servlet code gets executed JSP constructs get translated to Servlet code
ans) Interpretation of JSP code occurs
None of the above
6 When does Page translation occur?
ans) First time JSP page is accessed after its modified
Page translation happens for each request.
A or B None of the above
7 HTML text <H1>Hi</H1> when turned to servlet code is?
ans) out.print("<H1>Hi</H1>"
out.print("<H1><%Hi%></H1>"
out.print("<H1><!—Hi--!></H1>"
either b or c
8 JSP Hidden comment ? Would be sent only on first request to client
ans) Will never be sent to the client
Shall be sent to the client on every request.
None of the above
9 Syntax of Hidden Comment ?
<!-- comment [ <%= expression %> ] -->
<@<%-- comment --%@> ans) <%-- comment --%> None of the above
10 jspservice() is called for Initialising a servlet instance
Taking the instance out of service
ans) Each request, passing the request and response objects
All of the Above
11 To get <% in output use, ?
<%% <\\% ans) <\% None of the above
12 Format for expressions ? <%= expression= %> ans) <%= expression %> <!—expression--!> <^% expression %^>
13 Format for Scriplets ? ans) <% code %> <% =code %> <%! code %> <%!code =%> 14 Format for Declarations ? <% code %> <% =code= %> <#% code %#> ans) <%! code %> 15 To get the HostName ? <%= request.getHostName( ans) <%=
request.getRemoteHost(<% request.getHostName(
<% request.getRemoteHost(
16 Which of these is not a Request Response Out ans) None of the
predefined variable ?. above17 Which of these gives
information about the container ?
ans) ServletContext PageContext RequestDispatcher sendRedirect
18 For request.getRequestDispatcher(path ?
ans) we need to give the relative path of the resource
we need to give the absolute path of the resource
Absolute or Relative Path is irrelevant
None of the above
19 Which of these is not an implicit object ?
request pageContext ans) in out
20 How to use comments within a JSP page ?
<%-- the scriptlet is now commented out--%>
<!-- (c 2004 --> ans) Both A and B None of the abocve
21 Page Directive can control ? Which classes are imported What class the servlet extends
How multithreading is handled
ans) All of the Above
22 Format for import ? ans) <%@ page import="package.class" %>
<% page import="package.class" %>
<%! page import="package.class" %>
<%# page import="package.class" %>
23 Format for session attribute ?
<%@ page session=true %> <%@ !page session="true" %>
ans) <%@ page session="true" %>
<%@ page session "true" %>
24 Which of these is correct ? Page session attribute by default is false
Saves memory on server if you have a high-traffic site
Saves CPU time on server if you have a high-traffic site
ans) A and B
25 Format of Buffer Attribute ? <% page buffer="none" %@>
<%@@ page buffer="none" %>
ans) <%@ page buffer="none" %>
<%@page buffer="none">
26 Which of these is incorrect ? Buffering gives the size of the buffer used by the out variable
Buffering lets you set HTTP headers even after some page content has been generated
Servers are allowed to use a larger size than you ask for, but not a smaller size
ans) Default is system-specific, but must be at least 16kb
27 Error Page Attribute is ? <%@ page_errorPage="Relative URL" %>
<%@ page errPage="Relative URL" %>
ans) <%@ page errorPage="Relative URL" %>
<%@ page errorPage="Relative URL"@%>
28 ErrorPage Attribute is for ? ans) Page Specific Error Pages
Generalised Error Pages Global Error Pages None of the Above
29 Default value of isErrorPage attribute ?
TRUE ans) FALSE Null Undefined
30 Which of these about Extends Attribute is incorrect ?
Extends attribute is used to extend our own classes
Specifies parent class of servlet that will result from JSP page
Can help system from using high-performance custom superclasses
ans) A and C
31 isThreadSafe attribute tells the ?
ans) system when your code is not threadsafe
system when your code is threadsafe
servlet to implement Multiple Thread Model
A and B
32 Which of these holds good for Java Beans ?
Should have no public instance variables
Must have a zero-argument (empty constructor)
Persistent values should be accessed through get and set methods
ans) All of the Above
33 jsp:useBean is used for ? ans) Creating or accessing a bean
Delete a Bean Set properties of the bean
None of the above
34 jsp:getProperty is used for ? Modify the value of a bean property
ans) Read the value of a bean property
Both A and B None of the Above
35 Which of these is not a scope variable for <jsp:useBean>?
page request ans) output application
36 Which jsp tag can be used to retrieve a property of a bean?
jsp:useBean jsp:useBean.property jsp:useBean.getProperty ans)jsp:getProperty
jsp:property
37 Identify the implicit objects accessible to a jsp page that can store objects accessible across multiple requests.
page request response ans) application pageContext
38 Which of the following statements are valid JSP directive?
<%! int k = 10 %> <% int k = 10; %> <%=somevariable%> %@ taglib uri="https://www.abcd.com/tags/util" prefix="util" %
ans) <%@ page language="java" import="com.abc.*"%>
39 Which of the following interfaces declares the methods jspInit() and jspDestroy()?
javax.servlet.jsp.JSP javax.servlet.jsp.JspServlet ans)javax.servlet.jsp.JspPage
javax.servlet.jsp.HttpJspPage
javax.servlet.jsp.HttpJspServlet
40 Which of the following classes hides the implementation details and provides a standard API to the services provided by the servlet container to a jsp
HttpSession Servlet JspPage ServletContext ans) PageContext
page?
41 You have declared a useBean tag as:
<jsp:useBean id="man" class="animal.Human" scope="application"/>
In which type of object will this bean be kept?
Servlet HttpSession ans)ServletContext ServletConfig ApplicationContext
42 Which of the following packages are implicitly imported in the JSP page?
java.lang; java.util.* javax.servlets.* ans) javax.servlet.jsp.*
javax.servlet.jsp.tagext.*
43 Select the correct order that JSP methods are invoked by servlet container
jspInit(), jspService(), jspDestroy()
ans)jspInit(), _jspService(), jspDestroy()
_jspInit(), jspService(), _jspDestroy()
_jspInit(), _jspService(), _jspDestroy()
44 If precompile option set to false, for the first time request JSP page takes little more time then subsequent request, is it true?
ans)True FALSE
45 If JSP has option "isThreadSafe=false" set, only one instance will serve all the request.
TRUE ans) FALSE
46 There is no way in JSP you can ask container to have single threaded implementation?
TRUE ans) FALSE
47 JSPs cannot contain JAVA code.
TRUE ans) FALSE
48 JSP gets converted into a ans)True FALSE
servlet behind the scenes.
49 What will be the output of the following JSP code?
<html><body><% int a = 10; %><%! int a = 20; %><%! int b = 30; %>The value of b multiplied by a is <%= b * a %></body> </html>
The code will not compile The value of b multiplied by a is 30
ans)The value of b multiplied by a is 300
The value of b multiplied by a is 600
The value of b multiplied by a is 0
50 The jsp:plugin tag is used to insert the browser-specific OBJECTS and EMBED elements
ans)True FALSE
51 Which of the followings cannot be a scope of an object in a jsp page.
Application Request Page ans)Response
52 Which of the following gets or sets the bean in the servletContext container object?
<jsp:useBean id=”address” class=”test.addressBean” />
ans)<jsp:useBean id=”address” class=”test.addressBean” scope=”application” />
<jsp:useBean id=”address” class=”test.addressBean” scope=”servlet” />
None of the above
53 Which of the following is valid about include directive in jsp?
Used for dynamic inclusion ans) Used for static inclusion
54 Which tag in the jsp is used to define the error page.
None of the above location exception-type ans) error-page
55 Java Server Pages specification includes
ans)Script language declarations, scriplets and expressions
JSP standard actions JSP standard directives A portable tag extension mechanism
56 Which codeline must be set before any of the lines that use the PrintWriter
setContentWriter() setWriter() setPrintType() ans) setContentType()
57 Following method(s) cannot be overridden in the JSP page
jspDestroy() jspInit() jspService() getParameter()
58 Which of the following statement is true for the include directive
Can be used to incorporate contents from static documents
ans)It offers option of sharing local variables and better run time efficiency
Provides benefit of automatic recompilation
59 Which of the following are the JSP scripting elements
Declarations Scriptlets expressions ans) All the above
60 What tools can be used to generate the multiple views in jsp
xalan-Java ans) Saxon Jdk1.5 None of the above
61 Which of the following is legal JSP syntax to print the value of i.
<%int i = 1;%> <%= i; %> <%int i = 1;i; %> <%int i = 1%> <%= i %> <%int i = 1;%> <%= i %>
ans) <%int i = 1%><%= i; %>
62 Which of the following are correct?
JSP scriptlets and declarations result in code that is inserted inside the _jspService method.
The JSP statement <%! int x; %> is equivalent to the statement <jsp:scriptlet>int x;</jsp:scriptlet%>.
The following are some of the predefined variables that maybe used in JSP expression - httpSession, context.
ans) To use the character %> inside a scriptlet, you may use %\> instead.
63 Which of the following can not be used as the scope when using a JavaBean with JSP?
application session request ans)response page
64 The implicit JSP objects like request, response, and out are only visible in the _jspService() method.
ans)True False
65 Which of the following staments are correct about the following jsp lines:
<jps:useBean id=”name” class=”java.lang.String” />
It won't compile ans)It is a valid jsp line and it will print the variable called name
It will compile but it will always produce null as the output
It will work if you create a javabean class with only one variable of type java.lang.String
<%= name %>
66 Which of the following are mandatory elements of the tagLibrary descriptor file?
tlib-version jsp-version short-name tag ans) All of the above
67 What is the difference between forward and sendRedirect?
ans)RequestDispatcher: server-side redirect with request and response objects.sendRedirect : Client-side redirect with new request and response objects.
RequestDispatcher: client-side redirect with request and response objects.sendRedirect : Server-side redirect with new request and response objects.
68 What is difference between custom JSP tags and beans?
Custom tags are available only in JSP 1.2 and later, but beans can be used in all JSP 1.x versions.
ans) Custom tags are available only in JSP 1.1 and later, but beans can be used in all JSP 1.x versions.
69 Which method is used to retrieve a form value in a JSP or Servlet?
request.getAttribute(String)
response.getAttribute(String)
ans)request.getParameter(String)
response.getParameter(String)
70 Which of the following is not a valid JSP directive?
page include taglib ans) forward
71 The above tags in your jsp file will:
<jsp:useBean id="people" scope="session" class="bean.People"/><jsp:setProperty name="people" property="*"/>
Create a bean of People.class that will exist for all pages changed on this request.
ans) Retrieve a bean of People.class from the session if one exists or create a new one and store it in the session.
Create a Bean of People.class that is available to all classes in your application.
Create a bean of People.class that will go out of scope when the page is completed.
72 If you want to write a method in JSP, within what type of tags must you declare the method?
<@ @> <%@ %> <% %> ans) <%! %>
73 which of the following are <jsp:plugin > attributes?
type ans)codebase url align class
74 Syntax for Expression scripting element?
<% = Expression; %/> <jsp:Expression > Expression </jsp:Expression>
ans)<%= Expression; %> <%= Expression %>