Tag: java

Questions Related to java

The persistence of Person and Address information in an application is implemented via BMP entity beans. Each Person must have exactly one Address. If a Person contains the primary key for Address in a persistent field, how should you implement the Person

  1. The ejbRemove() method of Person invokes the remove() method of Address.

  2. The ejbStore() method of Person invokes the ejbStore() method of Address.

  3. The ejbPassivate() method of Person invokes the ejbPassivate() method of Address.

  4. The ejbLoad() method of Person invokes the findByPrimaryKey() method of Address-Home.

  5. The ejbLoad() method of Person invokes the ejbLoad() method of Address.


Correct Option: A,E
  1. Using ejbSelect() methods in session beans for specifying the selection criteria for a list

  2. Using ejbSelect() methods within ejbHome methods to return entities

  3. Using ejbSelect() methods to access fields of a bean instance

  4. Using ejbSelect() methods to perform operations not specific to a entity instance


Correct Option: D
  1. The native library directory in the classpath must be specified

  2. A message listener port must be defined

  3. The message listener service must be enabled

  4. A message passivation directory must be specified


Correct Option: B

A course enrolment application needs to define a JDBC resource reference for a DB2 database in the deployment descriptor. Assuming that the name of the resource reference is "enrolment", what is the appropriate JNDI declaration?

  1. java:comp/env/jdbc/db2/enrolment

  2. java:comp/env/jdbc/enrolment

  3. java:comp/env/enrolment

  4. java:jdbc/env/db2/enrolment


Correct Option: B

AI Explanation

To answer this question, we need to understand how JNDI (Java Naming and Directory Interface) declarations work for JDBC resource references.

JNDI is a naming service that allows Java software components to discover and access named resources. In the context of a Java EE application, JNDI is used to define and access resources such as databases.

In this question, the resource reference is named "enrolment" and it is a JDBC resource reference for a DB2 database. The appropriate JNDI declaration for this resource reference would be:

B. java:comp/env/jdbc/enrolment

The JNDI declaration consists of a hierarchical naming structure, starting with "java:comp/env" which refers to the "environment" namespace of the component. The "jdbc" component is then specified, followed by the name of the resource reference, which in this case is "enrolment".

Option A) java:comp/env/jdbc/db2/enrolment - This option is incorrect because it includes an additional "db2" component in the naming structure, which is not specified in the question.

Option C) java:comp/env/enrolment - This option is incorrect because it does not include the "jdbc" component in the naming structure, which is necessary for a JDBC resource reference.

Option D) java:jdbc/env/db2/enrolment - This option is incorrect because it includes "jdbc" and "db2" components in the naming structure, which are not specified in the question.

Therefore, the correct answer is B. java:comp/env/jdbc/enrolment. This option is correct because it follows the appropriate JNDI declaration for a JDBC resource reference named "enrolment".

  1. static fields in the entity bean

  2. an abstract persistence schema

  3. EJB Query Language definitions in the deployment descriptor

  4. the persistence-type attribute in the deployment descriptor


Correct Option: B
  1. declare the CMR member fields and add ejb-relationship definitions in the deployment descriptor

  2. implement the get/set methods for the CMR fields and add ejb-relationship definitions in the deployment descriptor

  3. implement the ejbLoad() and ejbStore() methods and add ejb-relationship definitions in the deployment descriptor

  4. declare abstract get/set methods for the CMR field and add ejb-relationship definitions in the deployment descriptor


Correct Option: D
  1. to enhance the SQL96 standard with additional options for complex relationships

  2. instead of the findByPrimaryKey() method, to define alternative selection criteria

  3. to specify a concrete implementation for the find and select methods of CMP entity beans

  4. for accessing User Defined data types and Stored Procedures in the database.


Correct Option: C

Container managed transactions are defined via trans-attributes in the deployment descriptor. When a session bean demarcates the transaction and calls an Entity Bean, what is the best transactional setting for the Entity Bean?

  1. Supports

  2. Never

  3. Required

  4. RequiresNew


Correct Option: C
  1. Specify the "context root" for each web application

  2. Generate access beans for any enterprise beans

  3. Assign alias names to the attributes of the Entity beans

  4. Map the Entity beans’ attributes to the relational database tables


Correct Option: A,D

How many JDBC driver types does Sun define?

  1. One

  2. Two

  3. Three

  4. Four


Correct Option: D