EJB MT solutions of Niit Ques. 51 to 75

EJB MT solutions of Niit Ques. 51 to 75












SNo: 51
Ques: In which of the following CMT transaction attributes the container is able to invoke the enterprise bean method in the client's transaction because the client method is executing in a transaction.
Options:
  1, REQUIRES_NEW
  2,  REQUIRED
  3, SUPPORTS
  4, NEVER
Answer: 2
Marks: 2

=============================================================

SNo: 52
Ques: Which of the following statements is true regarding BMT
Options:
  1, BMT is restricted to session bean only.
  2, BMT is restricted to session and message-driven beans only.
  3, BMT is restricted to message-driven bean only.
  4, To implement BMT transaction attribute for an enterprise bean, select it for each method.
Answer: 2
Marks: 2

=============================================================

SNo: 53
Ques: If a merge operation is performed on an entity in the detached state, what would be the new state of the entity
Options:
  1, Managed
  2, New
  3, Removed
  4, Non existent
Answer: 1
Marks: 2

=============================================================

SNo: 54
Ques: If a persist operation is performed on an entity in the removed state, what would be the new state of the entity
Options:
  1, Non existent
  2, Managed
  3, Detached
   4, New
Answer: 2
Marks: 2

=============================================================

SNo: 55
Ques: If the persist operation is performed on an entity in the new state, what will be the new state of the entity
Options:
  1, Removed
  2, Managed
  3, Detached
  4, Non existent
Answer: 2
Marks: 2

=============================================================

SNo: 56
Ques: Which of the following APIs is used for vendor-neutral access to directory services, such as LDAP
Options:
  1, JavaBeans Activation Framework (JAF) API
  2, JMS API
  3, JNDI API
  4, JavaMail API
Answer: 3
Marks: 2

=============================================================

SNo: 57
Ques: Which of the following options correctly defines a design rule for a session bean
Options:
  1, The class must be abstract.
  2, The class must have a public constructor that takes parameter.
  3, The class must be defined as public.
  4, The class must define the finalize method.
Answer: 3
Marks: 2

=============================================================

SNo: 58
Ques: Which of the following options is true regarding the callback method
Options:
  1, Each callback event can only have one callback method designated to handle it.
  2, A callback method cannot access entries in the bean's environment.
  3, Callback methods must throw application exceptions.
  4, Callback methods can have only public as the access modifier.
Answer: 1
Marks: 2

=============================================================

SNo: 59
Ques: Which of the following options defines a set of classes that work together to provide a hosting environment for a client
Options:
  1, Application client container
  2, Web server
  3, Web container
  4, EJB tier
Answer: 1
Marks: 2

=============================================================

SNo: 60
Ques: Which of the following xml files contains the deployment information for one or more enterprise beans
Options:
  1, ejb-jar.xml
  2, application.xml
  3, persistence.xml
  4, orm.xml
Answer: 1
Marks: 2

=============================================================

SNo: 61
Ques: Pamela, Recruitment Head for MagicJobs.com wants you to implement the Job Basket functionality in her company's job site. This Job Basket would allow registered users to store their searched jobs during their communication. The users can access their stored jobs by clicking on the Job Basket link. What will Pamela do to meet these requirements
Options:
  1,Pamela will create a stateless session bean.
  2,Pamela will create an Entity bean.
  3,Pamela will create a Message-driven bean.
  4,Pamela will create a state full session bean.
Answer: 4
Marks: 3

=============================================================

SNo: 62
Ques: Rita has been entrusted with the task of creating a hospital management site using EJB 3.0. After freezing on the technical architecture she is now implementing the EJBs, but has come across a problem. She is not sure about where to put entity beans related configuration data and has asked for your help. Which of the following options would you consider the best place to put configuration data of the entity bean
Options:
  1,The manifest.mf file
  2,The entity class using annotations
  3,The properties files
  4,The .ini files
Answer: 2
Marks: 3

=============================================================

SNo: 63
Ques: You have created a stateless session bean namely the EmployeeBean to store employee information. Apart from storing employee information you also want to log the time when employees are created. Therefore, you have created the logEmp method to log the time in a log file. For which of the following life-cycle events will you create logEmp method as a handler so that the method gets called when the employee bean is constructed
Options:
  1,PostConstruct callback event
  2,PreDestroy callback event
  3,PostActivate callback event
  4,PrePassivate callback event
Answer: 1
Marks: 3

=============================================================

SNo: 64
Ques: You have created a stateful session bean, and found that though the bean is getting the allocated resources, the deallocation is not happening properly. Which of the following options will you choose to rectify the issue
Options:
  1,You will deallocate the resources by overriding the finalize method in the bean class.
  2,You will deallocate the resources by creating a method to handle the PreDestroy life-cycle event of the bean.
  3,You will deallocate the resources by creating a method to handle the PrePassivate life-cycle event of the bean.
  4,You will deallocate the resources by restarting the server each time the Application Server is low on resources.
Answer: 2
Marks: 3

=============================================================

SNo: 65
Ques: You have developed a banking module by using a session bean namely, the AccountBean. In this bean, you have implemented the business interface Account that has debit and credit methods. Now, you want to test the AccountBean using a bean to verify if there are any issues in it. Therefore, you want to create a normal java class file and from its main method use the AccountBean. Do you think this is possible Give a reason for your choice.
Options:
  1,No, only servlets can act as client for a session bean.
  2,No, only JSPs can act as client for a session bean.
  3,Yes, you can use the injection service i.e. @EJB annotation to obtain a reference of a bean.
  4,Yes, you can directly instantiate a bean from a java class without any extra efforts.
Answer: 3
Marks: 3

=============================================================

SNo: 66
Ques: Greg has been assigned the task of creating entity beans for a banking site. One of the requirements for the banking site is that the application data of the entity beans should be fail-safe i.e. in case of system crash or shut-down the entity beans should be preserved. Which of the following options can help him in providing this fail-safe functionality
Options:
  1,The fail-safe functionality for entity beans can be provided by third party APIs which will write the data to the files in hard-disks for each update.
  2,The fail-safe functionality for entity beans can be provided by Java Persistence API which provides the mechanism for persisting the data.
  3,The fail-safe functionality for entity beans can be provided by own created API's which will write the data to the files in hard-disks for each update.
  4,The fail-safe functionality for entity beans cannot be provided as preserving the data is not possible in case of a system crash or system shut-down.
Answer: 2
Marks: 3

=============================================================

SNo: 67
Ques: You have been given a task to create entity beans for a shopping site. You have to create an entity bean that maps to the table PURCHASE_ORDER, instead of naming it as PurchaseOrder you want to name the class as POEntityBean. Additionally, the PURCHASE_ORDER table has an AMOUNT column and instead of naming the field as amount you want to name the field as totalAmount. Which of the following annotations will help you achieve this
Options:
  1,The entity annotations can be used to override both the table and the column name.
  2,The table annotations can be used to override the table name and the column annotations will help override the column name.
  3,The table names and column names cannot be overridden because you have to use PurchaseOrder as the bean and amount as the field.
  4,The bean annotation can be used to override both the table and the column name.
Answer: 2
Marks: 3

=============================================================

SNo: 68
Ques: You have been given a task to create entity beans for a shopping site. You have to create an entity bean PurchaseOrder , which maps to  the table PURCHASE_ORDER. PURCHASE_OREDR_ID is the primary key of the table and purchaseOrderId is the persistent field in the bean that is mapped to the primary key column. As soon as a purchase order record is created you want to auto-populate the primary key. Which of the following techniques you will use to achieve this
Options:
  1,The Id annotation will be used to denote that this is a primary key field and the ejb container will take care of auto-populating the field.
  2,The default constructor needs to be updated so that as soon as the bean is created purchaseOrderId will be initialized to max(PURCHASE_OREDR_ID)+1.
  3,The GeneratedValue annotation will be used in conjunction with Id annotation. The Id annotation denotes that this is a primary key field and the GeneratedValue denotes that this field should be auto-populated by the ejb container.
  4,The getter method purchaseOrderId needs to be updated so that the method returns the ID values correctly.
Answer: 3
Marks: 3

=============================================================

SNo: 69
Ques: You have created entity beans for an e-shopping site. These beans now need to be packaged and deployed on the customer's site. To package these beans, you need to provide information such as the data source, persistence unit name, and provider. Which of the following options do you think is the correct place to provide this information
Options:
  1,The information should be provided as annotations in each entity class.
  2,The information should be provided in .ini files.
  3,The information should be provided in persistence.xml.
  4,The information should be provided in manifest.mf file.
Answer: 3
Marks: 3

=============================================================

SNo: 70
Ques: Mary is working on her e-shopping module and has created entity beans named Product bean, for the table named PRODUCT. This table stores information about the items on the site such as price, brand, logo image etc. with image column being able to store images up to 5 MB. But now the customers are facing a performance issue as the Image column slows down the fetching of the Product bean. Which of the following options will Mary use to improve the performance of the Product bean
Options:
  1,Mary can change the fetch mode for the Lob column image to lazy.
  2,Mary can change the fetch mode for the entire entity to lazy.
  3,Mary can remove the Lob column image from the bean.
  4,Mary can ask the customer to upgrade his server with a faster machine.
Answer: 1
Marks: 3

=============================================================

SNo: 71
Ques: You are implementing a Human Resource Management site. For salary processing of employees at the end of each month you have created a message driven bean namely SalaryProcessor which implements TimedObject interface. You want that the ejbTimeout(Timer) method gets called always in a new transaction. Is this possible If yes then how
Options:
  1,It is not possible to execute ejbTimeout method always in a new transaction as message driven bean methods cannot be executed in a transaction.
  2,It is not possible to execute ejbTimeout method always in a new transaction as ejbTimeout method always executes in the client's transaction.
  3,It is possible to execute ejbTimeout method in a new transaction using Required transaction attribute.
  4,It is possible to execute ejbTimeout method in a new transaction using RequiresNew transaction attribute.
Answer: 4
Marks: 3

=============================================================

SNo: 72
Ques: You have implemented a social networking site. Your site sends general mails to the users each hour, for this you have created a timer which fires after each hour. For some reasons the server was shutdown for some hours. When the server was restored which of the following holds true for the expired timer notifications



Options:
  1,The expired timers will not be redelivered on server restart.
  2,The expired timers will be redelivered on server restart.
  3,The expired timers may or may not be redelivered on server restart; it depends upon the vendor of the application server.
  4,Only the interval timers that are expired will be redelivered on server restart.
Answer: 2
Marks: 3

=============================================================

SNo: 73
Ques: Sam needs to develop a Job Basket functionality for his job site. This Job Basket will allow the registered users to store their searched jobs in one place for the duration of their session. JobBasketBean implements a business interface that has methods to add and remove jobs. Sam has also added two interceptor methods interceptAdd and interceptRemove for intercepting addJob and removeJob methods. Identify whether it is possible for Sam to have different interceptor methods for different business methods Give a reason.
Options:
  1,Yes it is possible. Interceptors annotation can be used at method level to specify different interceptor classes for different business methods.
  2,Yes it is possible. AroundInvoke annotation can be used at method level to specify different interceptor methods for different business methods.
  3,Yes it is possible. Interceptors annotation can be used at class level to specify different interceptor classes and their association with different business methods.
  4,No it is not possible, same interceptor methods are executed regardless of which business method of the bean is executed.
Answer: 4
Marks: 3

=============================================================

SNo: 74
Ques: George is implementing a banking site. He has created two enterprise beans SavingAccount and CurrentAccount to handle saving accounts and current accounts respectively. He has created an AccountInterceptor class to intercept methods for both the beans. He has added interceptSavingAccount and interceptCurrentAccount methods to intercept business methods of SavingAccount and CurrentAccount beans respectively. How can he associate the bean's business methods with the interceptor methods
Options:
  1,It is not recommended to have more than one business interceptor method in a single interceptor class as it can produce unexpected results based upon vendor's implementation.
  2,Interceptor's annotation can be used at method level to specify different interceptor methods for different business methods.
  3,AroundInvoke annotation can be used at method level to specify different interceptor methods for different business methods.
  4,Interceptor's annotation can be used at class level to specify different interceptor classes and their association with different business methods.
Answer: 1
Marks: 3

=============================================================

SNo: 75
Ques: Greg is implementing a Job site. He has created a UserRegistration session bean for the registration. He has added the required business methods needed for the registration process to the bean. He wants to intercept the business methods calls of the bean. Which of the following options he can use for this
Options:
  1,It is not possible to intercept method calls.
  2,He can create an interceptor class which will be called when the business methods of the bean executes and use Interceptors annotation to associate the bean with the interceptor class.
  3,He can throw application exception at the end of processing from each method which will denote that the method is executed.
  4,He can write code in the business methods to write logs to a file and can continuously read the file to get if the business methods are executed.
Answer: 2
Marks: 3

0 Comments