Advance Java

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What is the result of attempting to access the following JSP page? <html> <body> <%!public String methodA(){ return methodB(); } %> <%!public String methodB(){ return "JAD Final Test"; } %> <h2><%= methodA() %></h2> </body> </html>

"JAD Final Test" is output to the result string web page.

What is the likely effect of calling a servlet with the HEAD HTTP method if that servlet does not have a doHead() method? (Choose one.)

200 response code: SC_OK

In ejb-jar.xml file. <persistence-type> element value is ________________

Bean or Container

Which of these are legal return types of the doAfterBody method defined in a class that extends TagSupport class. Select two correct answers.

EVAL_BODY_AGAIN SKIP_BODY

In EJB2.0, ejb-jar.xml deployment descriptor file must be placed in ______________folder.

META-INF

A JavaBeans component has the following field:

public void setEnabled(boolean enabled) public boolean getEnabled()

What will be the outcome of executing the following code? (Choose one.) public void doGet( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain"); response.setContentLength(4); PrintWriter out = response.getWriter(); out.write("What will be the response? "); out.write("" + response.isCommitted()); }

"What" is returned to the client.

Which of the following directories are legal locations for the deployment descriptor file? Note that all paths are shown as from the root of the machine or driver.(Choose one.)

/appserverIntallDirectory/webapps/webappName/WEB-INF/xml

What is output to the web page on the second access to the same instance of the following JSP? <html> <body> <%int x=0;%> <%= x++ %> </body> </html>

0

What gets printed when the following code snippet is compiled? select the one correct answer. <%int y=0;%> <%int z=0;%> <%for(int x=0;x<3;x++){%> <%z++;y;%> <%}%> <%if(z<y){%> <%=z%> <%}else{%> <%=z-1%> <%}%>

2

What is the likely effect of calling a servlet with the POST HTTP method if that servlet does not have a doPost() method? (Choose one.)

405 response code: SC_METHOD_NOT_ALLOWED.

What is the maximum number of parameter values that can be forwarded to the servlet from the following HTML form? (Choose one.) <html> <body> <h1>Chapter 1 Question 9</h1> <form action="ParamsServlet" method="get"> <select name="Languages" size="3" multiple> <option value="JAVA" selected>Java</option> <option value="CSHARP">C#</option> <option value="C" selected>C</option> <option value="CPLUSPLUS">C++</option> <option value="PASCAL">Pascal</option> <option value="ADA">Ada</option> </select> <input type="submit" name="button" /> </form> </body> </html>

7

Which of these is a correct fragment within the web-app element of deployment descriptor? Select the two correct answers.

<error-page><error-code>404</error-code><location>?error.jsp</location></error-page>

Which of the following represents the XML equivalent of this statement <%@ include file="a.jsp"%>. Select the one correct statement.

<jsp:directive.include file="a.jsp"/>

A bean with a property color is loader using the following statement <jsp:usebean id="fruit" class="Fruit"/> Which of the following statements may be user to print the value of color property of the bean? Select the one correct answer.

<jsp:getProperty name="fruit" property="color"/>

Which of these is a correct example of specifying a listener element resented by MyClass class? Assume myServlet element is defined correctly. Select the one correct answer.

<listener><listerner-class>MyClass</listener-class></listener>

Which of the following lines of code are correct?

@Entity public class Employees{ ..}

When a web server responds to a request from a browser or other Web client the response typically consists of. (choose one)

A status line, some response headers, a blank line, and the document.

Which of the following statements are correct about the status of the Http response? Select the one correct answer

A status of 200 to 299 signifies that the request was successful.

A bean with a property color is loaded using the following statement <jsp:usebean id="fruit" class="Fruit"/> What happen when the following statement is executes. Select the one correct answer. <jsp:setPropety name="fruit" property=""/>

All the properties of the fruit bean are assignet the values of input parameters of the JSP page that have the same name.

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?

ApplicationContext

The _________________ supplies business components, of enterprise beans

Bean provider

1) URL rewriting may be used when a browser is disabled cookies. 2) In URL encoding the session id is included as part of the URL.

Both 1 and 2 are true

Study the statements: The special directory/WEB-INF/lib contains Java class files-servlets and supporting code. The special directory/WEB-INF/class contains JAR files with supporting libraries of code.

Both1 and 2 a not true

What request header must be set for parameter data to be decoded from a form? (Choose one.)

Content-Type: application /x-www-form-urlencoded

A ______________has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number.

Cookie

The requirement for an online shopping application are: It must support millions of customers. The invocations must be transaction. The shopping cart must be persistent. Which technology is required to support these requirements?

EJB

Which of these is legal return types of the doEndTag method defined in a class that extends TagSupport class? Select two correct answers.

EVAL_PAGE SKIP_BODY

<html> <body> <%!intx%> <%=x;%> </body> </html>

Error in JSP Expression.

Consider the following form and servlet code. Assuming the user changes none of the default settings and presses submit, what will the servlet output in the response? (Choose one.) <form action="PrintParams?param1=First" method="post"> <input type="hidden" name="param1" value="First" /> <input type="text" name="param1" value="Second" /> <input type="radio" name="param1" value="Third" /> <input type="submit" /> </form> protected void doPost HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.write("<html>\n<head>\n<title>Print Parameters</title>\n</head>\n<body>"); String[] param1 = request.getParameterValues("param1"); for (int i = 0; i < param1.length; i++) { out.write(param1[i] + ":"); } out.write("\n</body>\n</html>"); out.close(); }

First:First:Second

Name the class that includes the getSession method that is used to get the HttpSession object.

HttpServletRequest

Which of the following methods can be used to add cookies to a servlet reponse?

HttpServletResponse.addCookie(Cookie cookie)

Under what circumstances can the HttpServletRequest.getHeaders(String name) method return null? (Choose one.)

If the container disallows access to the header information.

A java bean with a property color is loaded using the following statement <jsp:usebean id="fruit" class="Fruit"/> What is the effect of the following statement <jsp:sentproperty name="fruit" property="color"/> Select the one correct answer.

If there is a non-null request parameter with name color then its value gets assigned to color property of Java Bean fruit

What is the most likely outcome of running the following servlet code? (Choose one.) long date = request.getDateHeader("Host"); response.setContentType("text/plain"); response.getWriter().write("" + date);

IllegalArgumentException

Message-driven beans are clsses that implement 02 interfaces:

Javax.ejb.messageDrivenBean Javax.jms.MessagerListener

Study the statements about web.xml file: 1)The deployment descriptor file is called web.xml, and it must be located in the WEB-INF directory. 2)web.xml is in XML (extended markup language) format. Its root element is <web>.

Only statement 1 is true

What is the likely outcome of attempting to compile and run the following servlet code, assuming there is one cookie attached to the incoming request? 11 Cookie[] cookies = request.getCookies(); 12 Cookie cookie1 = cookies[0]; 13 response.setContentType("text/plain"); 14 String attributes = cookie1.getName(); 15 attributes += cookie1.getValue(); 16 attributes += cookie1.getDomain(); 17 attributes += cookie1.getPath(); 18 response.getWriter().write(attributes);

Output to the response including at least the name and value

Which of the HTTP methods below is not considered to be "idempotent"? (Choose one.)

POST

Create() method of entity home interface returns ________

Remote object

A ______________ session bean is a bean that holds conversations that span a single method call.

Stateless

What gets printed when the following JSP code is invoked in a browser. Select the one correct answer. <%= if(Math.random() < 0.5 %> hello <%= }else{ %> hi <%= } %>

The JSP file will not compile.

What is the likely outcome of attempting to run the following servlet code? String[] values = request.getHeaders("BogusHeader"); response.setContentType("text/plain"); response.getWriter().write(values[0]);

Won't run: 2 compilation errors.

Which of the following files is the correct name and location of deployment descriptor of a web application? Assume that the web application is rooted at\doc-root. Select the one correct answer

\doc-root\WEB-INF\web.xml

Which of the following are potentially legal lines of JSP cource?(Choose two.)

a. <jsp:useBean id="beanName1" class="a.b.myBean" type="a.b.Myinterface"/> b. <isp:setProperty name="beanName1" property="soleProp" value="<%=myValue%>"/>

What is the outcome of running the following servlet code? (Choose two.) public void doGet( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain;charset-UTF-8"); PrintWriter out = response.getWriter(); out.flush(); out.close(); System.out.println(response.isCommitted()); response.setContentType("illegal/value"); }

a. A blank page is returned to the client. b. "true" is output on the server's console.

What will be the result of pressing the submit button in the following HTML form? (Choose two.)

a. A request is sent with the HTTP method GET. b. The parameters fullName and sbmButton are passed to the web server in the request URL.

Which of the following are likely to found as request header fields? (Choose three.)

a. Accept b. Accept-Language c. From

Which of the HTTP methods below are likely to change state on the web server? (Choose three.)

a. DELETE b. POST c. PUT

Which of the following methods can be used to add cookies to a servlet response? (Choose two.)

a. HttpServletResponse.addCookie(Cookie cookie) b. HttpServletResponse.addHeader(String name, String value)

The top three value of EJB are (choose 3)

a. It is agreed upon by the industry. b. Portability is easier c. Rapid application development.

Which are EJB containers? (choose three)

a. JBoss b. IBM WebSphere c. BEA's WebLogic

Which of the following statements are true for <jsp:usebean>. Select the two correct answers.

a. The id attribute must be defined for <jsp:usebean> b. The <jsp:usebean> must include either type or class attribute or both

Identify statements that are always true about threads running through the service() method of a servlet with the following class declaration. (Choose two.)

a. There could be anything from zero to many threads running through the service() method during the time the servlet is loaded. b. D. If the init() method for the servlet hasn't run, no threads have yet been able to run through the service() method.

Which of the following are valid servlet methods that match up with HTTP methods? (Choose four.)

a. doGet() b. doPost() c. doOptions() d. doHead()

Which of the approaches below will correctly cause a client to redirect to an alternative URL? (In the code fragments below, consider that "response" is an instance of HttpServletResponse.) (Choose two.)

a. response.sendRedirect("index.jsp"); b. response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);

To send text output in a response. The following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer.

getOutputStream

Name the implicit variable to JSP pages that may be used to access all the other implicit objects.

pageContext

ejbCreate() method of entuty bean class returns ________________

primary key

A programmer is designing a class to encapsulate the information about an inventory item. A JavaBeans component is needed to do this. The InventoryItem class has private instance variables to store the item information: 10. private int itemId; 11. private String name; 12. private String description; Which method signature follows the JavaBeans naming standards for modifying the itemId instance variable? (Choose one.)

setItemId(int itemId)


संबंधित स्टडी सेट्स

ECON202 CHAPTER 9: INFLATION (the percentage increase (change) in the price level from one year to the next

View Set

Közgáz fogalmak I., Közgáz II.

View Set

chapter 10 tax part 1, chapter 9 tax part 2, chapter 9 tax

View Set

2nd Engineer Electricity and Electronics

View Set

ARRT Score Report: Patient Care INTERACTIONS (25)

View Set

Hiragana: Vowels, K and G sounds

View Set