0

web technology Online Quiz - 178

Description: web technology Online Quiz - 178
Number of Questions: 20
Created by:
Tags: web technology
Attempted 0/20 Correct 0 Score 0
  1. The value of the 'test' variable will be 2.

  2. The value of the 'test' variable will be 0.

  3. The value of the 'test' variable will be 1.

  4. The variable 'test' must be declared at global scope, else a run-time error will occur


Correct Option: C

Given the deployment descriptor for a Web Application is

  1. The Servlet will output 'javabeat null' in the Server Console.

  2. The Servlet will fail to load as the init param property 'no-name' is not mentioned in the deployment descriptor

  3. A NullPointerException will be raised as calling getServletConfig() in the init() method will return a null reference.

  4. The Servlet will output 'javabeat ' in the Server Console.


Correct Option: A

Which of the following suits best for Java?

  1. Object Oriented

  2. Write Once, Run Anywhere

  3. Compiled Programming language

  4. None of the above


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Object Oriented - This option is correct because Java is an object-oriented programming language. It supports the concepts of encapsulation, inheritance, and polymorphism.

Option B) Write Once, Run Anywhere - This option is correct because Java is designed to be platform-independent. The Java code can be compiled into bytecode and executed on any platform that has a Java Virtual Machine (JVM) installed. This concept is commonly referred to as "Write Once, Run Anywhere" (WORA).

Option C) Compiled Programming language - This option is incorrect because Java is both compiled and interpreted. Java source code is first compiled into bytecode using a Java compiler, and then the bytecode is interpreted by the JVM at runtime.

Option D) None of the above - This option is incorrect because both options A and B are applicable to Java.

The correct answer is B) Write Once, Run Anywhere. This option is correct because Java is designed to be platform-independent, allowing developers to write code once and run it on multiple platforms.

Sun released much of Java as open source software under the terms of GNU GPL. GPL Stands for ____________.

  1. Group Project Lead

  2. Group Project Location

  3. General Public License

  4. None of the above


Correct Option: C

For a given ServletResponse response, which retrieves an object for writing binary data?

  1. response.getWriter()

  2. response.getOutputStream()

  3. response.getOutputWriter()

  4. response.getWriter(Writer.OUTPUT_BINARY)


Correct Option: B

AI Explanation

To answer this question, you need to understand the difference between writing character data and binary data in a ServletResponse.

Option A) response.getWriter() - This option is incorrect because the getWriter() method retrieves a PrintWriter object that is used for writing character data. It is not used for writing binary data.

Option B) response.getOutputStream() - This option is correct because the getOutputStream() method retrieves a ServletOutputStream object that is used for writing binary data. This is the correct method to use when writing binary data to the ServletResponse.

Option C) response.getOutputWriter() - This option is incorrect because there is no getOutputWriter() method in the ServletResponse interface. This method does not exist.

Option D) response.getWriter(Writer.OUTPUT_BINARY) - This option is incorrect because there is no overloaded getWriter() method that accepts a parameter of type Writer.OUTPUT_BINARY. This method does not exist.

The correct answer is B) response.getOutputStream(). This option is correct because the getOutputStream() method retrieves a ServletOutputStream object that is used for writing binary data to the ServletResponse.

Which retrieves all cookies sent in a given HttpServletRequest request?

  1. request.getCookies()

  2. request.getAttributes()

  3. request.getSession (). GetAttributes()

  4. request.getSession ().getCookies()


Correct Option: A

Which two prevent a servlet from handling requests.? (Choose two.)

  1. The servlet's init method returns a non-zero status

  2. The servlet's init method throws a Servlet Exception

  3. The servlet's init method sets the Servlet Response's content type to null.

  4. The servlet's init method does NOT return within a time period defined by the servlet container


Correct Option: B,D

A JSP page needs to instantiate a JavaBean to be used by only that page. Which two jsp:useBean attributes must be used to access this attribute in the JSP page?

  1. id

  2. type

  3. name

  4. class


Correct Option: A,D

In form-based authentication, what must be included in the HTML returned from the URL specified by the element?

  1. a base-64 encoded user name and password

  2. a form that POSTs to the j_security_check URL

  3. an applet that requests the user name and password from the user

  4. a hidden field that supplies the login-constraint used by the application


Correct Option: B

How many Divisions a COBOL program normally consists

  1. 5

  2. 3

  3. 4

  4. 6


Correct Option: C

Which is the default font used in Cognos 8

  1. Andrew fonts

  2. Andale WT fonts

  3. Albany fonts

  4. Ad fonts


Correct Option: B

Which among the following is not a logging level used in Cognos 8

  1. Trace

  2. Minimal

  3. Audit

  4. Request


Correct Option: C

Which of the following statements are true about Java Servlets Technology?

  1. A Servlet is a Server-side entity that will rest only on the Server.

  2. The life-cycle management of Servlets is done by the programmer.

  3. Java Servlet Technology provides support for handling XML requests through a special Servlet called XmlServlet.

  4. A Servlet instance is created by the client during the first request to the Servlet Container.


Correct Option: A

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) A Servlet is a Server-side entity that will rest only on the Server - This option is correct. A Java Servlet is a server-side technology that runs on the server and handles client requests. It is not meant to be run on the client-side.

Option B) The life-cycle management of Servlets is done by the programmer - This option is incorrect. The life-cycle management of Servlets is handled by the Servlet Container, not the programmer. The Servlet Container is responsible for creating, initializing, invoking, and destroying Servlet instances.

Option C) Java Servlet Technology provides support for handling XML requests through a special Servlet called XmlServlet - This option is incorrect. Java Servlet Technology does not provide a special Servlet called XmlServlet for handling XML requests. Servlets can handle any type of request, including XML, but there is no special Servlet specifically for XML requests.

Option D) A Servlet instance is created by the client during the first request to the Servlet Container - This option is incorrect. The Servlet instance is not created by the client. It is created by the Servlet Container when the container is started or when the first request for the Servlet is received. The client only sends the request to the Servlet Container, and the container handles the creation and management of Servlet instances.

The correct answer is Option A. A Servlet is a Server-side entity that will rest only on the Server. This option is correct because Servlets are server-side technologies that are executed and managed on the server, not on the client-side.

Which of the following tags is used to set the timeout interval for HttpSession?

  1. session-timeout

  2. session-min-time

  3. session-inactive-time

  4. session-interval-time


Correct Option: A

Which of the following is used to define a Listener for HttpSessionListener class in Web Deployment Descriptor?

  1. A listener for HttpSession cannot be specified statically inside a Deployment Descriptor, instead it can be programmatically mentioned.


Correct Option: B

Which of the following listener(s) will be called when a Servlet Container initializes a Web Application?

  1. ServletContextListener

  2. ApplicationListener

  3. ApplicationContextListener

  4. None of the above.


Correct Option: A

Imagine that you want to set the inactive time for a particular servlet to 10 minutes. Which of the following is the preferred way to do it?

  1. HttpSession.setMinInactiveInterval(10);

  2. HttpSession.setMinInactiveInterval(10 * 60);

  3. HttpSession.setMaxInactiveInterval(10 * 60);

  4. HttpSession.setMaxInactiveInterval(10);


Correct Option: C

Which of the following method is used to send response in the form of character data to the client?

  1. HttpServletRequest.getWriter();

  2. HttpServlerResponse.getCharacterWriter();

  3. HttpServetRequest.getOutputStream()

  4. HttpServletResonse.getWriter();


Correct Option: D

AI Explanation

To answer this question, you need to understand the different methods available in the HttpServletResonse class for sending response data to the client.

Let's go through each option to understand why it is correct or incorrect:

Option A) HttpServletRequest.getWriter() - This option is incorrect because the getWriter() method is used to obtain a PrintWriter object that can send character text to the client. However, this method belongs to the HttpServletRequest interface, not the HttpServletResponse interface.

Option B) HttpServlerResponse.getCharacterWriter() - This option is incorrect because there is no method called getCharacterWriter() in the HttpServletResponse interface.

Option C) HttpServetRequest.getOutputStream() - This option is incorrect because the getOutputStream() method is used to obtain an OutputStream object that can send binary data to the client. It is not used to send character data.

Option D) HttpServletResonse.getWriter() - This option is correct because the getWriter() method in the HttpServletResponse interface is used to obtain a PrintWriter object that can send character data to the client. This is the correct method for sending response data in the form of character data.

The correct answer is D) HttpServletResonse.getWriter(). This option is correct because it provides the appropriate method for sending response in the form of character data to the client.

Assuming that you are developing a Web Application called 'myApp'. You have a file called secret.txt which is part of the original Application, but you don't want your clients to gain access to it. What is the preferred way to do this?

  1. Place the file 'secret.txt' in a directory called 'protected' in the 'myApp' Web Application.

  2. Place the file 'secret.txt' in a directory called 'private' in the 'myApp' Web Application.

  3. Place the file 'secret.txt' in a directory called 'WEB-INF' in the 'myApp' Web Application.

  4. Any filename starting with 'secret' are usually not accessible by the Clients, so this file can be places anywhere in the Web Application.


Correct Option: C

Which of the following methods can be used to retrieve all the attributes names from ServletContext?

  1. getAttributeNames()

  2. getAllAttributes()

  3. It is not possible to retrieve all the attributes in one call.

  4. getAttributes()


Correct Option: A
- Hide questions