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
-
config.createSessionFactory()
-
config.getSessionFactory()
-
config.buildSessionFactory()
-
config. SessionFactory.newInstance()
C
Correct answer
Explanation
In Hibernate 3 and earlier, the standard way to obtain a SessionFactory from a Configuration object is by calling config.buildSessionFactory(). The other methods do not exist on the configuration object.
-
integer
-
character
-
yes_no
-
None of the above
D
Correct answer
Explanation
In Hibernate, integer, character, and yes_no are all valid built-in basic value types. Since all of the listed options are valid basic types, 'None of the above' is the correct choice.
-
commit()
-
flush()
-
close()
-
list()
B
Correct answer
Explanation
The flush() method forces Hibernate to synchronize the in-memory state of the session with the underlying database by executing the necessary SQL statements (INSERT, UPDATE, DELETE) immediately, without committing the transaction.
-
echo_sql
-
show_sql
-
print_sql
-
display_sql
B
Correct answer
Explanation
The 'show_sql' property in Hibernate configuration enables logging of all executed SQL statements to the console. This is essential for debugging and understanding what SQL queries Hibernate generates. Other properties like echo_sql, print_sql, and display_sql are not standard Hibernate configuration properties.
-
criteria.setOrder( Order.asc("name") )
-
criteria.add( Order.asc("name") )
-
criteria.addOrder( Order.asc("name") )
-
criteria.addOrder( "name asc" )
C
Correct answer
Explanation
In Hibernate's Criteria API, the addOrder() method is used to apply sorting to the query results, passing an Order object such as Order.asc("name"). The methods setOrder and add are incorrect for this purpose.
-
Pass an instance of java.util.Properties to Configuration.setProperties().
-
Place hibernate.properties in a root directory of the classpath.
-
Set System properties using java -Dproperty=value.
-
All the above
D
Correct answer
Explanation
Hibernate accepts configuration through all three methods: passing Properties directly to Configuration object, placing hibernate.properties in classpath root, or setting System properties via -D flags. This flexibility allows different deployment and configuration strategies.
-
sess.createQuery("SELECT * FROM CATS").list();
-
sess.createSQLQuery("FROM CATS").list();
-
sess.createSQLQuery("SELECT * FROM CATS").list();
-
sess.createSQLQuery("from CATS", com.animals.Cat.class).list();
C
Correct answer
Explanation
In Hibernate, createSQLQuery is used to execute native SQL queries. The correct syntax to fetch all records from a table using a native SQL query is sess.createSQLQuery("SELECT * FROM CATS").list(). HQL syntax is used in createQuery.
-
Java Programming Language
-
Java Class file format
-
Java Application Programming Interface
-
Java Common Type System
-
Java Virtual Machine
-
Java Common Language Runtime
A,B,C,E
Correct answer
Explanation
The Java architecture is composed of the Java Programming Language, the Java Class file format, the Java API, and the Java Virtual Machine (JVM). Common Type System and CLR belong to the .NET framework.
-
To improve memory management.
-
To achieve Platform independence
-
To improve the Application performance
-
If Java API is not available for platform specific operation
-
For small applications
C,D
Correct answer
Explanation
Java Native Interface (JNI) is used to call platform-specific native libraries when a Java API is unavailable, or to write performance-critical code in C/C++ to optimize application execution speed.
-
JVM's default class loader is bootstrap
-
Java code is compiled into bytecode
-
JVM can run code in any language, provided it has been complied to bytecode meeting JVM specification
-
Java class file use little-endian format
-
Garbage collector is an integral part of JVM
D
Correct answer
Explanation
Java class files use big-endian byte order (most significant byte first) for all multi-byte data, making the statement that they use little-endian format false, and thus the correct answer.
-
Script language declarations, scriplets and expressions.
-
JSP standard actions
-
JSP standard directives
-
All the Above
D
Correct answer
Explanation
The Java Server Pages (JSP) specification defines scriptlet elements (declarations, scriptlets, and expressions), standard actions (like `), and directives (like<%@ page %>`), making all options correct.
-
Applet
-
Servlet
-
Application
-
Midlet
B
Correct answer
Explanation
JSP pages are compiled into Servlets by the JSP container. The first time a JSP is requested, it is translated into a Java source file for a Servlet, then compiled into bytecode. This Servlet generates the dynamic content for subsequent requests.
-
None of the above
-
location
-
exception-type
-
error-page
D
Correct answer
Explanation
In the web deployment descriptor (web.xml), the `` tag is used to map specific HTTP status codes or Java exception types to custom error handling pages.
-
It defines the standard tag that works the same everywhere
-
It is a single library and we can use it in multiple jsp containers
-
It has support for the common structural tasks like iteration and condition
-
All of the above
D
Correct answer
Explanation
JSP Tag Libraries (JSTL - JSP Standard Tag Library) define standard tags that work consistently across different JSP containers, are portable as single libraries usable in multiple containers, and provide built-in support for common structural patterns like iteration and conditional logic.
-
<% code fragment %>
-
<%= expressions %>
-
<%! Declarations %>
-
<%-- comment -- %>
D
Correct answer
Explanation
JSP comments are written using the <%-- comment --%> syntax. These comments are ignored by the JSP engine and are not sent to the client browser, unlike standard HTML comments or other JSP tags.