MCQs > IT & Programming > Enterprise Java Beans - EJB MCQs > Basic Enterprise Java Beans - EJB MCQs

Basic Enterprise Java Beans - EJB MCQ

1. Which of the following statements is not correct for an Enterprise Java Bean?


Answer

Correct Answer: Message beans send synchronous messages

Note: This Question is unanswered, help us to find answer for this one

2. The following method signature is found in an implemented entity bean named 'CustomerBean.' 'CustomerPK' is a class representing the primary key.

public CustomerPK ejbFindByPrimaryKey(CustomerPK key)
                throws FinderException

By context look up, a client gets the reference to the home object of the above bean, named 'custHome'. It gets the 'CustomerPK' class named 'PK' by a different method. The name of EJBObject is 'Customer', which represents a customer. Which of the following options will you select to invoke the above mentioned method in the client?



Answer

Correct Answer: Customer = custHome.findByPrimaryKey(PK);

Note: This Question is unanswered, help us to find answer for this one

3. Which of the following statements is not correct with regard to Passivation of beans?


Answer

Correct Answer: The process is possible in all the enterprise beans

Note: This Question is unanswered, help us to find answer for this one

4. Which of the following transaction modes are supported by Enterprise Java Beans?


Answer

Correct Answer: All of the above <br>

Note: This Question is unanswered, help us to find answer for this one

5. Which of the following statements is correct with regard to entity, session, and message-driven beans?


Answer

Correct Answer: All of them allow sending messages

Note: This Question is unanswered, help us to find answer for this one

6. What are the three classes that a Session EJB class must provide?


Answer

Correct Answer: EJB class, Home Interface, and EJB Remote Interface

Note: This Question is unanswered, help us to find answer for this one

7. One of the methods of your entity bean retrieves the names of all the patients admitted in a particular ward of a hospital. Using a connection named 'con', you want to execute the following query:

//secId is the parameter received by the method
String query = "SELECT admissionId, patientFirstName, patientLastName FROM ADMISSION WHERE sectionId=" + secId;

Which of the following options will help you execute the query?


Answer

Correct Answer: Statement stmt=con.createStatement(); <br>ResultSet rs=stmt.executeQuery(query);

Note: This Question is unanswered, help us to find answer for this one

8. SessionSynchronization Interface must be implemented to reset the instance variables.


Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

9. To disable the Passivaton process, set the EJBPassivationTimeout() variable to zero.


Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

10. Database connection pooling is beneficial because:


Answer

Correct Answer: Both a and b

Note: This Question is unanswered, help us to find answer for this one

11. Both RMI and CORBA define messaging protocols called:


Answer

Correct Answer: JRMP and IIOP

Note: This Question is unanswered, help us to find answer for this one

12. You are working with EJB2.0. You have to retrieve a previously saved handle to an EJBObject named 'bookEJBObject.' In order to restart the processing for that particular request, you need to get the remote interface. The following code has been written for the same:

1. ObjectInputStream stream =
2.                new ObjectInputStream(new FileInputStream(fileName));
3.
4. Handle bookHandle = (Handle) stream.readObject();
5.
6. BookRemoteInterface bookEjbObject = (BookRemoteInterface) XX() ;

Which of the following should substitute Method XX() of line 6?


Answer

Correct Answer: javax.rmi.PortableRemoteObject.narraow(bookHandle.getEJBObject(), BookRemoteInterface.class);

Note: This Question is unanswered, help us to find answer for this one

13. The EJB specification defines six distinct roles in the application development and deployment life cycle. Which of the following roles is not mentioned in it?


Answer

Correct Answer: EJB Developer

Note: This Question is unanswered, help us to find answer for this one

14. Which of the following constitute the enhancements made to EJB 2.0?


Answer

Correct Answer: All of the above <br>

Note: This Question is unanswered, help us to find answer for this one

15. Which of the following statements is not correct with regard to relationships in EJB?


Answer

Correct Answer: Directional relationship is always multidirectional<br>

Note: This Question is unanswered, help us to find answer for this one

16. Which of the following is not implemented by a stateless session bean?


Answer

Correct Answer: SessionSynchronization

Note: This Question is unanswered, help us to find answer for this one

17. You don't have any database recovery/backup system in place. Which of the following statements is true with regard to committed and uncommitted data of your entity bean?


Answer

Correct Answer: Both committed and uncommitted data survive a server crash if clustering is used<br>

Note: This Question is unanswered, help us to find answer for this one

18. Which of the following statements is correct with regard to JavaBeans and Enterprise JavaBeans?


Answer

Correct Answer: Both have some mechanism to tell the builder-tool/IDE about their functionality

Note: This Question is unanswered, help us to find answer for this one

19. Which of the following services does EJB container provide to a bean?


Answer

Correct Answer: All of the above <br>

Note: This Question is unanswered, help us to find answer for this one

20. The transaction attribute of a bean is set to 'TX_REQUIRES_NEW.' What do you infer about its behavior?


Answer

Correct Answer: It initiates a new transaction without even waiting for the previous one to conclude

Note: This Question is unanswered, help us to find answer for this one

21. Which of the following methods should be invoked by the container to get a bean back to its working state?


Answer

Correct Answer: EJBActivate()

Note: This Question is unanswered, help us to find answer for this one

22. Which of the following services does an EJB Server/Container provides to EJB?


Answer

Correct Answer: All of the above<br>

Note: This Question is unanswered, help us to find answer for this one

23. A heavy tool manufacturing company manages its business and production by using enterprise beans. A session bean named 'Status' is used to get the production status for the day. The following code gets the context:

Context initialContext = new InitialContext();

The bean provides a local client view. For the local home interface named 'StatusHome.' What should be the lookup?


Answer

Correct Answer: StatusHome statusHome = (StatusHome) javax.rmi.PortableRemoteObject.narrow(<br>initialContext.lookup("java:tools/env/ejb/status"),StatusHome.class);<br>

Note: This Question is unanswered, help us to find answer for this one

24. Which of the following statements is correct with regard to 'poison' message?


Answer

Correct Answer: It is not acknowledged by the consumer

Note: This Question is unanswered, help us to find answer for this one

25. An online shop employs a stateless session bean (named 'Eshop') to process the requests. 'Eshop' uses a declarative transaction management system. The following code is from the xml deployment descriptor file of the bean:

1.        <ejb-jar>
2.        <enterprise-beans>
3.         <session>
4.                <ejb-name>Eshop</ejb-name>
5.                <home>com.solution.EshopHome</home>
6.                <remote>com.solution.Eshop</remote>
7.                <local-home>com.solution.EshopLocalHome</local-home>
8.                <local>com.solution.EshopLocal</local>
9.                <ejb-class>com.solution.EshopBean</ejb-class>
10.
11.
12.         </session>
13.        </enterprise-beans>
14.        </ejb-jar>

The session and transaction attributes are to be coded in the lines numbered 10 and 11. Which of the following options should be used to make the bean work as expected?



Answer

Correct Answer: &lt;session-type&gt;Stateless&lt;/session-type&gt;<br>&lt;transaction-type&gt;Container&lt;/transaction-type&gt;

Note: This Question is unanswered, help us to find answer for this one

26. How do Enterprise Java Beans access the database?


Answer

Correct Answer: By using Java Database Connectivity

Note: This Question is unanswered, help us to find answer for this one

27. By interoperating via IIOP, an EJB can directly access:


Answer

Correct Answer: Existing production systems wrapped in CORBA interface

Note: This Question is unanswered, help us to find answer for this one

28. What is the restriction that EJB specification imposes on CMP fields?


Answer

Correct Answer: All of the above <br>

Note: This Question is unanswered, help us to find answer for this one

29. The interface that must be implemented by a stateless session bean is javax.ejb.SessionBean.


Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

30. Which of the following is a language in which IDL compiler of CORBA generates proxies and skeletons?


Answer

Correct Answer: Language mapping

Note: This Question is unanswered, help us to find answer for this one

31. You define an enterprise bean as follows:

Public class CalcSessionBean implements javax.ejb.SessionBean

Which of the following method definitions is not mandatory?



Answer

Correct Answer: public void ejbObject() {}

Note: This Question is unanswered, help us to find answer for this one

32. The PrimaryKey class is used to provide each entity bean with a ____________:


Answer

Correct Answer: Unique, serializable identity

Note: This Question is unanswered, help us to find answer for this one

33. Which of the following is a name of the design pattern not associated with EJB?


Answer

Correct Answer: Entity Command

Note: This Question is unanswered, help us to find answer for this one

34. The methods declared in Session Bean interface are known as Callback (methods).


Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

35. What will happen to the running session beans if the EJB container crashes or restarts?


Answer

Correct Answer: They will get destroyed

Note: This Question is unanswered, help us to find answer for this one

36. The method ejbCreate() allows session beans to perform initializations. Which of the following methods should be called by the container before ejbCreate()?


Answer

Correct Answer: newInstance() and setSessionContext()

Note: This Question is unanswered, help us to find answer for this one

37. A client wants to access Enterprise Java Bean for some processing. The first step will be looking up the class that implements its home interface. Which of the following should be used for the purpose?


Answer

Correct Answer: JNDI

Note: This Question is unanswered, help us to find answer for this one

38. The principal finder method that must be implemented by every entity bean class is:


Answer

Correct Answer: ejbFindByPrimaryKey()

Note: This Question is unanswered, help us to find answer for this one

39. Which of the following statements is incorrect with regard to the process of Instance Pooling in EJB?


Answer

Correct Answer: None of the above <br>

Note: This Question is unanswered, help us to find answer for this one

40. We are saving a handle to an EJBObject named 'bookEJBObject' for an online book shop:

1. javax.ejb.Handle bookHandle = _____________;
2.
3. ObjectOutputStream stream =
4.                 new ObjectOutputStream(new FileOutputStream(fileName));
5.
6. stream.writeObject(bookHandle);
7. stream.close();

Which of the following methods should be filled in the blank?


Answer

Correct Answer: bookEJBObject.getHandle()

Note: This Question is unanswered, help us to find answer for this one

41. A pre-cached instance is used to load state information on creation of an EJB.


Answer

Correct Answer: False<br>

Note: This Question is unanswered, help us to find answer for this one

42. Which of the following must be implemented by a JMS message-driven bean?


Answer

Correct Answer: MessageListener and MessageDrivenBean interfaces

Note: This Question is unanswered, help us to find answer for this one

43. Which of the following statements are correct with regard to EJB QL?


Answer

Correct Answer: All of the above <br>

Note: This Question is unanswered, help us to find answer for this one

44. Which of the following statements is correct with regard to the method ejbSelect()?


Answer

Correct Answer: It can return values that are defined as CMP-TYPE <br>

Note: This Question is unanswered, help us to find answer for this one

45. ______ bean supports asynchronous execution.

Answer

Correct Answer: Message Driven

Note: This Question is unanswered, help us to find answer for this one

46. EJB's remote interfaces are split into what two groups?

Answer

Correct Answer: Class and Instance methods.

Note: This Question is unanswered, help us to find answer for this one

47. _____ is a model that enables beans to be saved in an XML format.

Answer

Correct Answer: Long-term persistence

Note: This Question is unanswered, help us to find answer for this one

48. How many clients can access a stateless session bean?

Answer

Correct Answer: One.

Note: This Question is unanswered, help us to find answer for this one

49. The listener type of an event must be a descendent of _______.

Answer

Correct Answer: java.util.EventListener

Note: This Question is unanswered, help us to find answer for this one

50. True or False? EJB technology allows users to isolate their business logic away from the data layer by storing with the presentation layer.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

51. _______ is not true of customizers.

Answer

Correct Answer: Extend the java.beans.Customizer interface.

Note: This Question is unanswered, help us to find answer for this one

52. What is EJB's transaction processing responsible for?

Answer

Correct Answer: It divides the processed information into smaller pieces.

Note: This Question is unanswered, help us to find answer for this one

53. What happens if concurrent access is attempted on a single bean?

Answer

Correct Answer: The request is rerouted to a different interest by the container.

Note: This Question is unanswered, help us to find answer for this one

54. The ______ is an abstract representation of the container system to access a bean through methods that manage actions of the bean.

Answer

Correct Answer: home interface

Note: This Question is unanswered, help us to find answer for this one

55. True or False? When an Application Exception occurs, the ejb container intercepts the exception, rolls back the transaction, and starts the clean up tasks.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

56. A ______ property notifies listeners when its value changes.

Answer

Correct Answer: bound

Note: This Question is unanswered, help us to find answer for this one

57. When you create a combination of read-only and read-write EJBs, what pattern are you creating?

Answer

Correct Answer: Read-mostly.

Note: This Question is unanswered, help us to find answer for this one

58. Are class methods declared by the Home interface tied to a specific instance?

Answer

Correct Answer: No.

Note: This Question is unanswered, help us to find answer for this one

59. ______ is an advantage of a session bean over an entity bean.

Answer

Correct Answer: A session bean is less resource intensive.

Note: This Question is unanswered, help us to find answer for this one

60. True or False? Enterprise Java bean is a form of Java bean.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

61. Use the ______ interface when you need complete control over your bean's serialization.

Answer

Correct Answer: Externalizable

Note: This Question is unanswered, help us to find answer for this one

62. True or False? Client code can access local beans.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

63. A ______ property consults listeners before making a change and any one of the listeners may veto the change.

Answer

Correct Answer: constrained

Note: This Question is unanswered, help us to find answer for this one

64. A ______ class for a bean changes how a bean appears in the builder tool by telling which properties should be listed first or which should be hidden.

Answer

Correct Answer: BeanInfo

Note: This Question is unanswered, help us to find answer for this one

65. If a bean is handling transactions via JTA API, what is happening?

Answer

Correct Answer: It is handling the transaction rather than a container.

Note: This Question is unanswered, help us to find answer for this one

66. When is it ideal to use a singleton session bean?

Answer

Correct Answer: When the list you will be using is static, such as a price list.

Note: This Question is unanswered, help us to find answer for this one

67. What two security mechanisms does EJB primarily use?

Answer

Correct Answer: JCE and JAAS

Note: This Question is unanswered, help us to find answer for this one

68. True or False? Any public method that is not part of a property definition is a bean method.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

69. True or False? A boolean property in a bean class must have a public get method.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

70. _____ is not an EJB interface.

Answer

Correct Answer: BeanContext

Note: This Question is unanswered, help us to find answer for this one

71. What is responsible for the user interface logic on a client machine?

Answer

Correct Answer: EJB Client.

Note: This Question is unanswered, help us to find answer for this one

72. Can underlying table schemas be changed automatically by your EJB container?

Answer

Correct Answer: Yes, but they must be configured to do so.

Note: This Question is unanswered, help us to find answer for this one

73. Which of the following is a JNDI scope?

Answer

Correct Answer: Module

Note: This Question is unanswered, help us to find answer for this one

74. _______ provides a means for modifying the appearance and behavior of a bean within an application builder so it meets your specific needs.

Answer

Correct Answer: Customization

Note: This Question is unanswered, help us to find answer for this one

75. _______ class does not support serialization.

Answer

Correct Answer: Thread

Note: This Question is unanswered, help us to find answer for this one

76. What three files are used to control WebLogic Server EJB?

Answer

Correct Answer: ejb-jar.xml, weblogic-ejb-jar.xml, weblogic-cmp-jar.xml

Note: This Question is unanswered, help us to find answer for this one

77. Object _____ means converting an object into a data stream and writing it to storage.

Answer

Correct Answer: serialization

Note: This Question is unanswered, help us to find answer for this one

78. What is an example of a stateful session bean process?

Answer

Correct Answer: The checkout process in a web store.

Note: This Question is unanswered, help us to find answer for this one

79. What happens if two calling clients attempt to access a single bean?

Answer

Correct Answer: The requests are serialized by a container.

Note: This Question is unanswered, help us to find answer for this one

80. What kind of programming does Java Message Service provide for EJB?

Answer

Correct Answer: Event-driven programming.

Note: This Question is unanswered, help us to find answer for this one

81. What has replaced the deployment descriptor in the newest version of EJB, 3.0?

Answer

Correct Answer: Java annotations.

Note: This Question is unanswered, help us to find answer for this one

82. How are EJB's two interfaces referred to?

Answer

Correct Answer: Home and Remote.

Note: This Question is unanswered, help us to find answer for this one

83. _____ is NOT a method of the EntityBean Interface.

Answer

Correct Answer: ejbNewBean()

Note: This Question is unanswered, help us to find answer for this one

84. A ____ tag is used to represent an instance of a class in an XML bean archive.

Answer

Correct Answer: <class>

Note: This Question is unanswered, help us to find answer for this one

85. True or False? A bean class can fire off any type of event except custom events.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

86. True or False? The properties of a bean affect its appearance or internal state.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

87. What is the javax.ejb.spi package used for?

Answer

Correct Answer: A service provider interface.

Note: This Question is unanswered, help us to find answer for this one

88. How are stateless session beans different than stateful session beans?

Answer

Correct Answer: They are automatically thread-safe.

Note: This Question is unanswered, help us to find answer for this one

89. ______ beans represent persistent data storage.

Answer

Correct Answer: Entity

Note: This Question is unanswered, help us to find answer for this one

90. True or False? EJB is a client-side model that encapsulates the business logic of an application.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

91. What is asynchronous pattern?

Answer

Correct Answer: The non synchronous operation of business services within EJB.

Note: This Question is unanswered, help us to find answer for this one

92. What is the EJB container responsible for assigning?

Answer

Correct Answer: JNDI names for EJB session beans.

Note: This Question is unanswered, help us to find answer for this one

93. _____ bean stores data for a particular user for a single session.

Answer

Correct Answer: Session

Note: This Question is unanswered, help us to find answer for this one

94. Do clients of EJB instantiate beans directly?

Answer

Correct Answer: No. They need a reference from the EJB container.

Note: This Question is unanswered, help us to find answer for this one

95. A bean _______ is the code responsible for managing beans and the various interfaces.

Answer

Correct Answer: container

Note: This Question is unanswered, help us to find answer for this one

96. A class is serializable if a class's inheritance hierarchy implements _________.

Answer

Correct Answer: Serializable or Externalizable

Note: This Question is unanswered, help us to find answer for this one

97. What bean represents real-world objects?

Answer

Correct Answer: Entity bean.

Note: This Question is unanswered, help us to find answer for this one

98. What does it mean when business objects have a state?

Answer

Correct Answer: They are limited to a single client at a time.

Note: This Question is unanswered, help us to find answer for this one

99. When injection is not available, what is the alternative?

Answer

Correct Answer: Java Naming and Directory Interface

Note: This Question is unanswered, help us to find answer for this one

100. What are ACID transactions responsible for?

Answer

Correct Answer: Reliable database transactions.

Note: This Question is unanswered, help us to find answer for this one

101. Which of the following contains the EJB container that provides the services for the EJB component?

Answer

Correct Answer: EJB Server.

Note: This Question is unanswered, help us to find answer for this one

102. True or False? A session bean can only be stateless.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

103. In passivation, the opposite method from ejbPassivate() is _______.

Answer

Correct Answer: ejbActivate()

Note: This Question is unanswered, help us to find answer for this one

104. What is CMC?

Answer

Correct Answer: Container-managed concurrency.

Note: This Question is unanswered, help us to find answer for this one

105. What is concurrency control?

Answer

Correct Answer: The ensuring that two operations within EJB are generated correctly.

Note: This Question is unanswered, help us to find answer for this one

106. Which of the following is one of WebLogic Server's caching abilities?

Answer

Correct Answer: Caching between transactions.

Note: This Question is unanswered, help us to find answer for this one

107. If you wanted to control the WebLogic Server EJB’s configuration, what is one of the files you would use?

Answer

Correct Answer: ejb-jar.xml

Note: This Question is unanswered, help us to find answer for this one

108. EJB is a framework for _____.

Answer

Correct Answer: Java

Note: This Question is unanswered, help us to find answer for this one

109. What file format are all of the descriptor files in?

Answer

Correct Answer: XML

Note: This Question is unanswered, help us to find answer for this one

110. EJB stands for ________.

Answer

Correct Answer: Enterprise Java Beans

Note: This Question is unanswered, help us to find answer for this one

111. What format is the deployment descriptor document in?

Answer

Correct Answer: XML

Note: This Question is unanswered, help us to find answer for this one

112. What is RMI-IIOP?

Answer

Correct Answer: Java Remote Method Invocation interface.

Note: This Question is unanswered, help us to find answer for this one

113. EJB applications are deployed on a ____ compliant Application Server.

Answer

Correct Answer: J2EE

Note: This Question is unanswered, help us to find answer for this one

114. True or False? Enterprise Java 2.0 specification introduces the concept of local beans.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

115. _______ is not a tag used in an XML bean archive to define a primitive type.

Answer

Correct Answer: <object>

Note: This Question is unanswered, help us to find answer for this one

116. The _______ file is an XML file used to describe the properties of a bean.

Answer

Correct Answer: Deployment Descriptor

Note: This Question is unanswered, help us to find answer for this one

117. The _______ is the most common exception class.

Answer

Correct Answer: EJBException

Note: This Question is unanswered, help us to find answer for this one

118. Where are the EJB classes utilized by applications retained?

Answer

Correct Answer: Within the javax.ejb package.

Note: This Question is unanswered, help us to find answer for this one