Computer Knowledge

Java Enterprise and Web Technologies

2,279 Questions

Java enterprise and web technologies questions focus on J2EE architecture, web services like SOAP, and servlet functionalities. These topics frequently appear in IT officer and specialist scale examinations. Regular practice ensures familiarity with enterprise application components.

HttpServlet methodsSOAP and web servicesEJB architecture rolesJ2EE componentsJSP servlet callingUDDI concepts

Java Enterprise and Web Technologies Questions

Multiple choice technology packaged enterprise solutions
  1. Required

  2. Not Required

  3. Load needs to Implement

  4. None of the Above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Hibernate does NOT require persistent classes to implement Serializable. While implementing Serializable can be useful for caching or transporting objects across layers (like in web sessions), it's not mandatory for basic Hibernate persistence. Hibernate uses reflection and proxy mechanisms that don't depend on serialization.

Multiple choice technology architecture
  1. Command

  2. Context

  3. Flyweight

  4. Builder

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The Command pattern encapsulates a request as an object, allowing you to parameterize clients with different requests, queue or log requests, and support undoable operations. This is exactly what the question describes. Context manages external state, Flyweight shares intrinsic state, and Builder constructs complex objects step-by-step.

Multiple choice technology architecture
  1. Visitor

  2. Façade

  3. Bridge

  4. Chain of responsibility

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The Chain of Responsibility pattern avoids coupling the sender of a request to its receiver by giving multiple objects a chance to handle the request. It passes the request along a chain of receiving objects until an object handles it. This pattern is commonly used in logging, event handling, and processing pipelines.

Multiple choice technology architecture
  1. Business Delegate

  2. Service Locator

  3. Facade

  4. View Helper

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Business Delegate pattern hides the implementation details of business services, including lookup and access details of EJB architecture. It reduces coupling between presentation tier and business tier.

Multiple choice technology programming languages
  1. a) Mapping files can be added to Configuration in the application code

  2. b) They can be configured in hibernate.cfg.xml using the <mapping> elements

  3. c) both a and b

  4. d) none of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Hibernate mapping files can be configured both programmatically via Configuration.addMapping() and declaratively via hibernate.cfg.xml using elements. Both methods are valid and commonly used depending on the setup preference.

Multiple choice technology programming languages
  1. a) session.createQuery();

  2. b) session.createCriteria();

  3. c) session.createSQLQuery();

  4. d) session.lod();

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

HQL (Hibernate Query Language) is used through session.createQuery() method. The session.createCriteria() method is for Criteria queries (deprecated in Hibernate 5+), session.createSQLQuery() is for native SQL queries, and session.load() is a retrieval method, not a query creation method.

Multiple choice technology programming languages
  1. Required

  2. b) Not Required

  3. c) None of the above

  4. All of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Hibernate does NOT require persistent classes to implement Serializable. However, implementing Serializable becomes necessary in specific scenarios like storing objects in HttpSession, using distributed second-level caches, or when detaching and reattaching objects across different JVMs.

Multiple choice technology programming languages
  1. 1) It is a valid line that can be used to initialize the servlet that implements the jsp file.

  2. 2) It won't compile as no identifer can start with jsp not _jsp.

  3. 3) It will serve as the servlet initialization if the function's name is _jspInit.

  4. 4) There is no way to initialize a jsp's implementation class servlet.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The jspInit() method is the correct JSP lifecycle method for initialization. You can declare it in a declaration element <%! ... %> as shown, and the JSP container will call it when the servlet is initialized. Option B is incorrect because identifiers can start with jsp. Option C is wrong because the method name is jspInit(), not _jspInit() (which is for internal implementation details).

Multiple choice technology programming languages
  1. 1) It won't compile.

  2. 2) It will print the default client's Web browser locale.

  3. 3) It will print the default web server Locale.

  4. 4) It will the first language specified in the Accept-Language request's header.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The code won't compile because it tries to use the implicit object 'request' inside a declaration <%! ... %>. Declaration elements are for class-level variables and methods, where request (which is method-local in _jspService()) is not accessible. Additionally, there's a variable name mismatch - class1 is declared but class is used. Option A correctly identifies this as a compilation error.

Multiple choice technology programming languages
  1. 1)It won't compile

  2. 2)It will print the session id.

  3. 3)It will produce a NullPointerException as the getSession(false) method's call returns null, cause no session had been created.

  4. 4)It will produce an empty page.

Reveal answer Fill a bubble to check yourself
B Correct answer
Multiple choice technology programming languages
  1. 1) ServletContext doesn't have one of these two methods.

  2. 2) String and InputStream

  3. 3) URL and InputStream

  4. 4) URL and StreamReader

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The ServletContext interface defines getResource(String path), which returns a URL object, and getResourceAsStream(String path), which returns an InputStream object.

Multiple choice technology programming languages
  1. 1) By calling the method with an absolute path as the argument

  2. 2) By enconding the path with HttpServletResponse.endcodeURL method

  3. 3) By enconding the path with HttpServletResponse.endcodeRedirectURL method

  4. 4) If you use sendRedirect the session is lost.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

To maintain a session during a client-side redirect, you must encode the redirect URL using HttpServletResponse.encodeRedirectURL(String url), which appends the session ID if cookies are disabled. encodeURL is used for normal links.

Multiple choice technology web technology
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

J2EE applications are not limited to web-based applications only. J2EE (Java Enterprise Edition) supports multiple application types including web applications, application clients, Enterprise JavaBeans, and other distributed enterprise components. The statement is false.

Multiple choice technology web technology
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

JavaBeans are a reusable component model for Java, but they are not specifically J2EE components. JavaBeans can be used in any Java application context. J2EE components include servlets, JSP pages, EJBs, and other enterprise-specific technologies. The statement is false.