EJB Certification Free Mock Exam

Question 1 of 13 [Introduction to Java EE]
Java EE applications can be designed by either EJB-Centric or Web-centric approach.
Select the application characteristics suited to implement EJB-Centric approach.
Choice 1Transaction
Choice 2Security
Choice 3Distribution
Choice 4Concurrency Management
Choice 5Loading Java Applet
Choice 6Loading Native Interface
Question 2 of 13 [Implementing Session Beans]
Scenario:A developer from EPractize Labs creates a stateful session bean named TestSessionManager for managing Skill Evaluation Lab test session. It is assumed that TestSessionManager clients might not remove the bean when ending their session. EJB load testing team concluded that the number of concurrent sessions are greater than the defined bean cache size. The developer must consider that the state of the TestSessionManager bean can be influenced by either passivation or timeout.
Which three actions should the EJB developer take to make the TestSessionManager behave correctly in passivation and timeout situations?
Choice 1Release references to resources in a @Remove annotated method.
Choice 2Re-establish references to resources in an @lnit annotated method.
Choice 3Release references to resources in a @PreDestroy annotated method.
Choice 4Release references to resources in a @PrePassivate annotated method.
Choice 5Re-establish references to resources in a @PostActivate annotated method.
Question 3 of 13 [Accessing Session Beans]
Select valid stateless session bean code
Choice 1 @Stateless
public class WelcomeBean {
public String welcome() {
String message = propertiesBean.getProperty("welcome.message");
return message;
}
Choice 2
@EJB
public class WelcomeBean implements Welcome{
public String welcome() {
String message = propertiesBean.getProperty("welcome.message");
return message;
}
}
Choice 3 @StatelessEJB
public class WelcomeBean implements WelcomeLocal, WelcomeLocalRemote{
public String welcome() {
String message = propertiesBean.getProperty("welcome.message");
return message;
}
}
Question 4 of 13 [Advanced Session Bean Concepts]
You want to develop a visitor counter in your Java EE application. Your architect wants to use EJB 3.1 singleton session beans to achieve the same.
Select the correct singleton class
Choice 1 @Singleton
@Lock(READ)
public class VisitorCounterBean {
private int count;
@Lock(READ)
public String getCount() {
return count;
}@Lock(WRITE)
public void setCount(int countArg) {
count = countArg;
}
}
Choice 2 @Stateless
@Singleton
@Lock(READ)
public class VisitorCounterBean {
private int count;
public String getCount() {
return count;
}@Lock(WRITE)
public void setCount(int countArg) {
count = countArg;
}
}
Choice 3@SingletonEJB
@Lock(READ)
public class VisitorCounterBean {
private int count;
public String getCount() {
return count;
}@Lock(WRITE)
public void setCount(int countArg) {
count = countArg;
}
}
Question 5 of 13 [Advanced Session Bean Concepts]
EJB 3.1 addresses packaging complexity by removing the restriction that enterprise bean classes must be packaged in an ejb-jar file.
Which of the following statements are true about EJB packaging?
Choice 1EJB classes can be directly placed in the .war file, using the same packaging guidelines that apply to web application classes.
Choice 2We can place EJB classes under the WEB-INF/classes directory or in a .jar file within the WEB-INF/lib directory.
Choice 3We can place EJB classes under the WEB-INF/classes directory and NOT in a .jar file within the WEB-INF/lib directory.
Choice 4We can place EJB classes JAR files under the WEB-INF/lib directory and NOT in WEB-INF/classes directory.
Question 6 of 13 [Singleton Session Bean]
You are writing an EJB client to access GiftManager Bean EJB. Note that GiftManagerBean does not implement local or remote interfaces.
Select the correct code to access GiftManagerBean
Choice 1
@EJB
private GiftManager giftManager
Choice 2
@EJB
private GiftManagerBean giftManagerBean;
Choice 3We cannot access EJB without local or remote interfaces
Question 7 of 13 [Developing Java EE Applications Using Messaging]
You want to change the order of interceptor method execution specified by the Bean Provider. You got just ejb-jar file (which includes only class files) of your EJB from your Bean Provider.
Which represents the solution to this problem?
Choice 1No solution is possible under these conditions.
Choice 2The Deployer can add metadata annotations to the ejb-jar.
Choice 3The Application Assembler can add metadata annotations to the ejb-jar.
Choice 4The System Administrator can add interceptor binding information at runtime, using vendor-specific tools.
Choice 5The Application Assembler can add a deployment descriptor to the ejb-jar that includes interceptor binding information.
Question 8 of 13 [Developing Message-Driven Beans]
One of the powerful features introduced in EJB 3.1 is the ability to invoke session bean methods asynchronously.
Select the annotation to modify a Session bean method to be asynchronous
Choice 1@Asynchronous
Choice 2@AsynchronousMethod
Choice 3@MethodAsynchronous
Question 9 of 13 [Using Timer Services Objectives]
Which is a valid Post Construct method in a message-driven bean class?
Choice 1
@Post Construct
public boolean init() { return true; }
Choice 2
@Post Construct
private static void init() {}
Choice 3
@PostConstruct
private void init() {}
Choice 4
@Post Construct
public static void init() {}
Question 10 of 13 [Implementing Interceptor Classes and Methods]
Which of the following statements are true about the Java EE 6 client-view of a message-driven bean?
Choice 1References to message destinations can be injected.
Choice 2As of EJB 3.0, references to message destinations cannot be looked up in the clients JNDI namespace.
Choice 3Clients of a message destination need to know that the destination is listened to by a pool of message consumers.
Choice 4Clients of a message destination do NOT need to know that the destination is listened to by a message-driven bean.
Question 11 of 13 [Implementing Transactions]
You are developing EJB 3.1 stateful session bean and defined Required transaction attribute for method aMethod(). Which of the following statements would hold true when a non-transactional remote client invokes aMethod?
Choice 1Container starts a new transaction and invokes the bean method with it.
Choice 2The method throws TransactionRequiredException to the client.
Choice 3The method throws RemoteException to the client.
Choice 4The bean method executes without a any error.
Question 12 of 13 [Implementing Security]
Code :
Given the following method permissions.
<method-permission>
<unchecked/>
<method>
<ejb-name>TestManager</ejb-name>
<method-name>*</method-name>
</method>
</method-permission> <method-permission>
<role-name>admin</role-name>
<method>
<ejb-name>TestManager</ejb-name>
<method-name>getTests</method-name>
</method>
</method-permission>
Which of the following statement is true?
Choice 1The first method permission element is invalid.
Choice 2Only a client using manager role can access the getTests() method.
Choice 3Any client using any role can access the getTests() method.
Choice 4Only a client who has no security identity can access the getTests() method.
Question 13 of 13 [Using EJB Technology Best Practices]
Which statement is true about the Timer service in an EJB 3.1 stateless session bean?
Choice 1The timeout callback method contains the business logic that handles the timeout event.
Choice 2The timeout callback method must throw RemoteException.
Choice 3The timeout callback method must throw application exceptions to report business logic failures.