Computer Knowledge

Java Enterprise and Web Technologies

2,183 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 web technology
  1. the page has only one form

  2. the page has multiple forms and the developer is familiar with developing GUI appliciations

  3. Java Script is not preferred

  4. light weight web application is being developed

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

JSF (JavaServer Faces) is a component-based framework ideal for complex pages with multiple forms and complex UI logic, especially when developers have GUI application experience. JSP is simpler and more suitable for lightweight applications with minimal form complexity. JSF provides better state management and event handling for complex interfaces.

Multiple choice technology
  1. True

  2. False

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

The Java Virtual Machine (JVM) is indeed the run-time system that executes Java bytecode. It provides the environment where Java programs run, handling memory management, garbage collection, and platform independence through the 'write once, run anywhere' principle.

Multiple choice technology
  1. Random Memory Interface

  2. Remote Method Invocation

  3. Random Method Invocation

  4. Remote Memory Interface

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

RMI stands for Remote Method Invocation, which allows Java objects running in one JVM to invoke methods on objects running in another JVM. This enables distributed Java applications where objects can communicate across different machines or processes.

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
C Correct answer
Explanation

Calling request.getSession(false) when no session currently exists returns null. Attempting to call .getId() on that null reference immediately triggers a NullPointerException.

Multiple choice technology programming languages
  1. 1) web-resource-name

  2. 2) url-pattern

  3. 3) http-method

  4. 4) auth-constraint

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

The web-resource-collection element in web.xml requires web-resource-name (to identify the collection) and url-pattern (to specify which URLs are protected). The http-method element is optional - if omitted, it applies to all HTTP methods. The auth-constraint element is separate from web-resource-collection. Options A and B are correct.