Toughest Questions for Oracle EJB (SCBCD 5.0) Certification

Moderator: Site Manager

Post Reply
admin
Site Admin
Posts: 8065
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Toughest Questions for Oracle EJB (SCBCD 5.0) Certification

Post by admin » Sun Oct 10, 2010 5:57 pm

Toughest Questions for - Oracle EJB 5.0 (SCBCD) Certification

Q. No. 1
What can a client infer if it receives an exception while calling a method of an EJB 3.0 bean?

(a) If the client receives EJBException, it means the method has been invoked but not completed normally.(b) If the client receives an application exception, the client can assume that the bean still exists and continue calling the enterprise bean.(c) If a client receives EJBTransactionRolledbackException, the client knows for certain that the transaction has been marked for rollback.(d) If the client receives EJBException, it can assume that the transaction will never commit.


Q. No. 2
Given : A client of a session bean calls a method on the bean and the method throws a system exception.


Which of the following statements are correct?

(a) If the transaction attribute of the method is NOT_SUPPORTED, NEVER, or SUPPORTS, the client will get EJBException.(b) If the bean method runs in the context of a transaction that the container started immediately before dispatching the business method, the client will get EJBException.(c) If the bean method runs in the context of the caller’s transaction, the client will get EJBException.(d) If the bean method runs in the context of a transaction that the container started immediately before dispatching the business method, the client will get EJBTransactionRolledbackException.


Q. No. 3
Identify correct statements regarding JPQL...

(a) Comparison of a non null value with a NULL value always yields false.(b) Two NULL values are considered to be equal.(c) Path expressions that contain NULL values during evaluation return NULL values.(d) Operators IS NULL and IS NOT NULL only work for field type of String.


Q. No. 4
Identify the true statements regarding transactions in EJB 3.0.

(a) It allows Isolation levels to be specified in the deployment descriptor.(b) It allows Isolation levels can only be used programmatically using proprietary database vendor interface.(c) It allows nested transactions.(d) It does not allow a EJB 3.0 Entities to manage their own transactions.


Q. No. 5
The remove(entityObject) method on EntityManager has been called. Which of the following are correct?
The remove(entityObject) method on EntityManager has been called. Which of the following are correct?

(a) If entityObject is new, IllegalStateException will be thrown.(b) If entityObject is already removed, IllegalStateException will be thrown.(c) It will never throw IllegalArgumentException.(d) None of these.


Q. No. 6
What is the responsibility of the bean provider if his session bean method gets an exception during execution
of its method body?

(a) If the bean can recover from the exception, the method should throw an application exception without setting the transaction for rollback only.(b) If it is a checked exception that is not listed in the throws clause of the method and if the bean cannot recover from this exception, the bean method should throw the javax.ejb.EJBException that wraps the original exception.(c) If it is a checked exception, from which the bean cannot recover, throw the exception as it is.(d) For an application exception, he must ensure that if the current transaction commits, there will be no loss of data integrity.


Q. No. 7
Which of the following are true about EntityManager.clear() method?

(a) It will cause all managed entities to either persist or be removed in/from the database.(b) It will cause all managed entities to become detached.(c) Any changes made to the entities will be saved to the database if the entities have not already been flushed to the database.(d) It should be called after the EntityManager has been closed.(e) If called when a transaction is active, the transaction will be rolled back.(f) If called when a transaction is active, the transaction will be committed.(g) This method may be called on container-managed entity managers.


Q. No. 8
The following code appears inside an EJB method. Which of the given statements are correct?

...
UserTransaction ut = validContext.getUserTransaction();
ut.begin();
//some valid code
ut.setRollbackOnly();
//some more valid code
ut.commit();

(a) The bean might be a Message Driven Bean.(b) The bean must not be a stateful session bean.(c) This must not be a stateless session bean.(d) This code will throw an exception at runtime.(e) This code will not compile.(f) The bean must be an EJB 3.0 entity with bean managed persistence.(g) Upon execution of this code, the container ensures that the transaction is not committed.


Q. No. 9
A persistence archive file named ejbplusPU.jar contains the following files:

com/enthu/ejbplus/Account.class
com/enthu/ejbplus/Person.class
META-INF/persistence.xml
META-INF/orm.xml

Given that Account and Person classes contain all the mapping information in the form of annotations,
which of the above files will always be examined by the container for mapping information when this jar
is deployed?
(Assume that classes Account and Person belong to com.enthu.ejbplus package.)

(a) Only the class files.(b) The class files and persistence.xml(c) Class files, persistence.xml file, and orm.xml(d) persistence.xml and orm.xml


Q. No. 10
Given:

Bean A with transaction attributes of "Supports" for all its methods.
Bean B with transaction attributes of "Never" for all its methods.
A client having a transaction context calls a method mA() on bean A, which in turns calls a method
mB() on Bean B.

Assuming all invocations are local, which of the following statements is correct?

(a) The client's transaction will be marked for roll back.(b) The client will get a javax.ejb.EJBException but it can continue with the same transaction.(c) The client will get a javax.ejb.EJBTransactionRolledbackException(d) The bean B instance will be discarded.(e) mA() will get a javax.ejb.TransactionNotSupportedException(f) None of the above.


Q. No. 11
Identify the correct statements about the primary key class of an entity?

(a) It cannot consist of multiple fields.(b) It must be serializable and must also override equals and hashCode methods appropriately.(c) In an entity class hierarchy, the class for which the primary key has been defined must be the root class of the hierarchy and must be an Entity class.(d) If property-based access is used, the properties of the primary key class must be public or protected.(e) The primary key class must be public or default accessed and must have a public no-arg constructor.


Q. No. 12
The developer of a MDB wants to ensure that a message is redelivered if the onMessage method of the bean
throws a RuntimeException. What should he do?

(a) Nothing. This is guaranteed by the container.(b) He should use container managed transactions with transaction attribute of REQUIRED.(c) He should use Bean managed transaction, catch any exception, and call UserTransaction.rollback().(d) He should use Bean managed transactions and use JMS API for message acknowledgement.


Q. No. 13
The following sequence of events happens -

1. Client 1 retrieves an Account entity. Its status property has a value of "outstanding".
2. Client 2 performs a bulk update on Accounts changing their status property to "normal".
3. Client 1 updates the account balance of the Account entity that it was accessing and merges the instance.
3. Client 1 updates the account balance of the Account entity that it was accessing and merges the instance.

Assuming that Account entity uses @Version, identify the correct statements.

(a) The update by Client 1 will fail with OptimisticLockException.(b) After 3, the status of the account instance will be "normal".(c) Update by Client 1 will succeed without any exception but the account balance will not be updated.(d) None of these.


Q. No. 14
A developer wants to execute a query in the current transaction within a session bean method. What should
he do to ensure that all changes made to the persistence context in the same transaction before executing
the query are visible to the query?

(a) Set the flush mode on the EntityManager to FlushModeType.COMMIT.(b) Set the flush mode on the EntityManager to FlushModeType.COMMIT and on Query to FlushModeType.AUTO.(c) Set the flush mode on the EntityManager to FlushModeType.AUTO and on the Query to FlushModeType.COMMIT.(d) Set the flush mode on the EntityManager to FlushModeType.AUTO and should not set flush mode on Query.(e) Don't set flush mode at all.(f) Set flush mode on Query to FlushMode.AUTO.


Q. No. 15
Consider the following code occuring in a MyBean code. It updates the database and sends a message to
a queue named Q1. The message driven bean (not same as MyBean) associated with the queue requires a transaction
and updates the database upon receiving a message.

11. public void myBeanMethod()
12. {
...
21. UserTransaction ut = ejbContext.getUserTransaction();
22. ut.begin();
23. queueSender.send(message); //sends a message to a queue Q1.
24. stmt.executeUpdate(query1);
25. ut.rollback();
...
30. }

Assuming that all the variables are properly defined and used, what will happen if the MDB associated
with the queue Q1 rolls back the transaction but does not throw any exception?

(a) Changes made by the bean code at line 24 will be committed.(b) Line 25 will throw an Exception(c) The message will be sent to the queue.(d) The message will be sent to the queue but the changes made to the database by the MDB will not be committed.(e) The container will resend the message to the queue.(f) Neither the message is sent nor any database changes get committed.


Q. No. 16
Identify the correct statements about entity class lifecycle listeners.

(a) It cannot be defined for a mapped superclass.(b) It can be defined only for an entity class.(c) It can be defined in any entity listener class.(d) It may be defined in any class in the class hierarchy as long as the leaf class is an entity class.


Q. No. 17
Which of the following information can be retrieved by a session bean method using its SessionContext?
Which of the following information can be retrieved by a session bean method using its SessionContext?

(a) State of the current transaction.(b) Identity of the caller.(c) References to the bean's local and remote home interfaces if available.(d) Caller's role.


Q. No. 18
Given:

Bean A with transaction attributes of "RequiresNew" for all its methods.
Bean B with transaction attributes of "Supports" for all its methods.
A client having a transaction context calls a method mA() on bean A, which in turns calls a method
mB() on Bean B.

Assuming all invocations are local, which of the following statements is correct if mB() encounters a
system exception?

(a) The client's transaction will be marked for roll back.(b) The client will get a javax.ejb.EJBException but it can continue with the same transaction.(c) The client will get a javax.ejb.EJBTransactionRolledbackException(d) The bean B instance will be discarded.(e) mA() will get a javax.ejb.EJBTransactionRolledbackException(f) The bean A instance will NOT be discarded.(g) Changes made to the database by mA(), will be commited.


Q. No. 19
Consider the following interfaces and bean code:

public class XYBean implements XLocal, YLocal, XRemote
{
//...valid code
}


public interface XLocal {
String xM1();
}

public interface YLocal {
String yM1();
}

public interface XRemote {
void remoteM1(Data d);
}

Assuming appropriate package and import statements, what should the developer do to make sure that the
bean exposes two local and one remote interfaces?

(a) Add the following to XYBean before class declaration:
@Local(XLocal.class)
@Local(YLocal.class)
@Remote(XRemote.class)(b) Add the following to XLocal, YLocal, and XRemote interfaces respectively:
@Local, @Local, @Remote(c) The developer can add @Local to either of the local interfaces but not both and @Remote to the remote interface.(d) This cannot be done.(e) This can only be done through deployment descriptor.(f) Only add @Remote to the remote interface. No need to do anything for the local interfaces.(g) Add the following to XYBean before class declaration:
@Local( {XLocal.class, YLocal.class })
@Remote(XRemote.class)


Q. No. 20
Identify the correct statements regarding the activation and passivation of a session bean?

(a) The container must use Java Serialization mechanism to passivate a bean.(b) The container must restore all serializable fields (transient and non-transient) while activating a bean.(c) The container must reset all transient fields to their default values while activating a bean.(d) All non serializable fields must be set to null in the method annotated with @PrePassivate.(e) None of these.


Q. No. 21
Identify FALSE (i.e. INCORRECT) statements about JPQL.

(a) It is vendor independent.(b) JPQL queries are compiled into the database specific SQL queries by the container.(c) It can accomodate complex joins involving multiple tables.(d) It can be used to update EJB 3.0 Entities.(e) It can be used to insert new rows into the database.(f) It can be used to select values only from tables that have been mapped to the abstract persistent schema.


Q. No. 22
Consider the following code occuring in a MyBean code. It updates the database and sends a message to
a queue named Q1. The message driven bean associated with the queue is a BMT MDB. It updates the database
within a transaction upon receiving a message.


11. public void myBeanMethod()
12. {
...
21. UserTransaction ut = ejbContext.getUserTransaction();
22. ut.begin();
23. stmt.executeUpdate(query1);
24. queueSender.send(message); //sends a message to a queue Q1.
25. ut.commit();
...
30. }

Assuming that all the variables are properly defined and used, what will happen if the MDB associated
with the queue Q1 rolls back the transaction but does not throw any exception?

(a) Changes made by the bean code at line 23 will be committed.(b) Line 25 will get a javax.transaction.TransactionRolledbackException(c) Changes made by the bean code at line 23 will be committed but the message sent at line 24 will not be sent.(d) Changes made by the bean code at line 23 will not be committed but there will be no exception.(e) The message will be resent to the MDB.


Q. No. 23
Identify correct statements about EJB 3.0 compliant application server.

(a) javax.naming.InitialContext is guaranteed to provide a JNDI name space to a bean.(b) The JNDI namespace of a bean not required to make available any web service interfaces to the bean.(c) The JNDI name space must make available the business interfaces of other enterprise beans in the application.(d) The EJB specification does not require that all the enterprise beans deployed in a container be presented
with the same JNDI API name space.


Q. No. 24
Which of the following is true regarding EJB technology?

(a) EJB technology allows integration with Java Messaging Service.(b) EJB technology provides lightweight access to local clients.(c) EJB technology allows integration of database schema using Object to relational mapping protocol.(d) EJB technology mandates that persistance be handled by the EJB container.


Q. No. 25
Consider the following code snippet for an EJB.


Context ctx = new InitialContext();
String locale = (String) ctx.lookup("java:comp/env/locale");
String actuallocale = determineActualLocale(); //Assume that this is a valid call.
if(!locale.equals(actuallocale))
{
ctx.rebind("java:comp/env/locale", actuallocale);
}

Which of the following options are correct?

(a) It will throw a javax.naming.OperationNotSupported exception.(b) It will not throw any exception but the rebinding will be ignored.(c) It will rebind the JNDI name to the new locale value.(d) It will not compile.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest