Wednesday 26 July 2017

NIIT EJB MT SOLUTION ~ GNIIT HELP

SNo: 1
Ques: What is an Entity Manager
Options:
  1, It is the service object that manages entity life-cycle instances.
  2, It is a set of entity instances.
  3, It is a unique value used by the persistence provider.
  4, It is a value that is used to map the entity instance to the corresponding table row in the database.
Answer: 1
Marks: 1

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

SNo: 2
Ques: Which of the following properties of an entity specifies the propagation of the effect of an operation to associated entities
Options:
  1, Cascade
  2, Ownership
  3, Cardinality
  4, Direction
Answer: 1
Marks: 1

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

SNo: 3
Ques: Which of the following entity manager methods forces the synchronization of the database with entities in the persistence context
Options:
   1, flush
  2, refresh
  3, contains
  4, merge
Answer: 1
Marks: 1

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

SNo: 4
Ques: Which of the following options is true about mapped superclass
Options:
  1, It is a plain Java technology interface that is designated with the MappedSuperclass annotation.
  2, It is created to provide state and the corresponding object/relational mapping information to child classes through the inheritance mechanism.
  3, It can be passed as arguments to methods of the EntityManager or Query interfaces.
  4, It is a target of a persistent relationship.
Answer: 2
Marks: 1

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

SNo: 5
Ques: Which of the following options is a static query expressed in metadata
Options:
  1, Named query
  2, Query language
  3, Query object
  4, Native query
Answer: 1
Marks: 1

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

SNo: 6
Ques: Which of the following options can be compiled to a target language, such as SQL, of a database or other persistent store
Options:
  1, Java Persistence Query Language
  2, Named query
  3, Query object
  4, Native query
Answer: 1
Marks: 1

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

SNo: 7
Ques: What requirement does the GROUP BY clause impose on the SELECT clause
Options:
  1, Item that appears in the SELECT clause including the arguments to an aggregate function, must also appear in the GROUP BY clause.
  2, Item that appears in the SELECT clause, other than as an argument to an aggregate function, must also appear in the GROUP BY clause.
  3, Item that appears in the GROUP BY clause must also appear in the SELECT clause.
  4, Item that appears in the SELECT clause should not appear in the GROUP BY clause.
Answer: 2
Marks: 1

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

SNo: 8
Ques: Which of the following methods will you use to control the start position of the result set in a query
Options:
  1, setFirstResult(int startPosition)
  2, SetFirstResult(int startPosition)
  3, startPosition()
  4, setParameter(int startPosition)
Answer: 1
Marks: 1

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

SNo: 9
Ques: Which of the following QL statements operates on the underlying persistence store, such as database
Options:
  1, SELECT
  2, UPDATE
  3, DELETE
  4, WHERE
Answer: 1
Marks: 1

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

SNo: 10
Ques: Which of the following callback annotations can be used to designate a callback method defined in an entity class
Options:
  1, PostConstruct
  2, PreDestroy
  3, PostActivate
  4, PreRemove
Answer: 4
Marks: 1

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

SNo: 11
Ques: Which of the following statements identifies an interceptor
Options:
  1, It is a class that works in conjunction with a bean class to interpose on business method invocations and receive life-cycle callback notifications.
  2, It is a method that intercepts the invocation of a business method of a session bean or listener method of a message-driven bean.
  3, It is a method that intercepts life-cycle events generated by session bean and message-driven bean instances.
  4, It is a method that intercepts the invocation of a business method of a entity bean or listener method of a message-driven bean.
Answer: 1
Marks: 1

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

SNo: 12
Ques: Which of the following TimerService interface method is used to create an absolute time notification timer
Options:
  1, createTimer(long initialDuration, long intervalDuration, Serializable info)
  2, createTimer(long duration, Serializable info)
  3, createTimer(Date expiration, Serializable info)
  4, createTimer(Date initialExpiration, long intervalDuration, Serializable info)
Answer: 3
Marks: 1

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

SNo: 13
Ques: Which of the following tasks will you perform in a method that contains a valid reference to a timer object
Options:
  1, Notify the enterprise bean about all expired timers
  2, Interrogate a timer callback notification
  3, Obtain a list of outstanding timer notifications
  4, Process a timer callback notification
Answer: 2
Marks: 1

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

SNo: 14
Ques: By using which of the following methods the enterprise bean obtains a reference to the TimerService object
Options:
  1, ejbTimeout method
  2, getTimers method
  3, getNextTimeout method
  4, getTimerService method
Answer: 4
Marks: 1

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

SNo: 15
Ques: Which of the following options is used to implement Container Managed Transaction (CMT) to methods
Options:
  1, To apply CMT to the methods of an enterprise bean, the application assembler should, on a method-by-method basis, consider the suitability of accepting the EJB 3.0 default transaction policy.
  2, To implement CMT to methods, you must code the required transaction policy in the enterprise bean method.
  3, To apply CMT to methods, do not specify the transactional behavior of the enterprise bean.
  4, To implement CMT methods, you must code the required transaction policy in the session bean method.
Answer: 1
Marks: 1

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

SNo: 16
Ques: What will you do when a client method invocation does not have an accompanying transaction context
Options:
  1, Run the enterprise bean method in a new transaction
  2, Run the enterprise bean method in the caller's transaction context
  3, Suspend the callers transaction context and run the enterprise bean method in a new transaction
  4, Suspend the callers transaction context and run the enterprise bean method without a transaction
Answer: 1
Marks: 1

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

SNo: 17
Ques: Which of the following CMT transaction attributes is applicable for methods that must always execute in the callers transaction
Options:
  1, REQUIRED
  2, SUPPORTS
  3, REQUIRES_NEW
  4, MANDATORY
Answer: 4
Marks: 1

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

SNo: 18
Ques: Which of the following CMT transaction attributes is supported by the following enterprise beans:
Stateless session  bean
Stateful session bean
Message-Driven bean
Options:
  1, REQUIRED
  2, SUPPORTS
  3, REQUIRES_NEW
  4, MANDATORY
Answer: 1
Marks: 1

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

SNo: 19
Ques: In which of the following authentication methods a public key certificate is exchanged in Secure Socket Layer (SSL)
Options:
  1, HTTP basic
  2, Client certificate
  3, Form-based
  4, Identification
Answer: 2
Marks: 1

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

SNo: 20
Ques: Which of the following options defines JTA
Options:
  1, It enables the software components to initiate and monitor distributed transactions.
  2, It specifies the implementation of a transaction manager.
  3, It is used to integrate an application server with an external security infrastructure.
  4, It is used for vendor-neutral access to directory services, such as NIS+.
Answer: 1
Marks: 1

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

SNo: 21
Ques: Which of the following JAVA EE platform roles uses tools to produce JAVA EE applications and components
Options:
  1, System Administrator
  2, Application Component Provider
  3, Application Assembler
  4, Tools Provider
Answer: 2
Marks: 1

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

SNo: 22
Ques: Which of the following options is a server-side client resource
Options:
  1, Database tier
  2, MDB
  3, Entity bean
  4, Session bean
Answer: 4
Marks: 1

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

SNo: 23
Ques: Which of the following options is used to obtain security information of the EJB objects
Options:
  1, EJBObject
  2, SessionContext
  3, Context
  4, @Resource
Answer: 2
Marks: 1

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

SNo: 24
Ques: Which of the following access modifier cannot be applied to a callback method
Options:
  1, transient
  2, protected
  3, public
  4, private
Answer: 1
Marks: 1

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

SNo: 25
Ques: Which of the following options assigns the name of the entity class as the default name to the database table
Options:
  1, Java Persistence API
  2, @Table annotation
  3, LOB annotation
  4, Basic annotation
Answer: 1
Marks: 1

SNo: 26
Ques: Which of the following option does not hold true when a client method is invoked with an accompanying transaction context
Options:
  1, Run the enterprise bean method without a transaction.
  2, Run the enterprise bean method in a new transaction.
  3, Cannot Run the enterprise bean in a new transaction.
  4, Run the enterprise bean method in the caller's transaction context
Answer: 3
Marks: 2

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

SNo: 27
Ques: Which of the following options defines the authorization process
Options:
  1, It is defined as the process that ensures the confidentiality and integrity of the information transported across the network.
  2, It is defined as the process that facilitates the secure deployment of an application in diverse environments.
  3, It is defined as the process of verifying what the user's identity is and ensuring that they are who they say they are.
  4, It is defined as the process of allocating permissions to authenticated users.
Answer: 4
Marks: 2

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

SNo: 28
Ques: Which of the following options is true regarding role identity
Options:
  1, A role represents a user in the native security domain.
  2, A role is an entity that can be authenticated by an authentication protocol in a security service that is deployed in an enterprise.
  3, A role is a group of principals sharing a unique set of permissions.
  4, A role has predefined credential requirements associated with itself.
Answer: 4
Marks: 2

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

SNo: 29
Ques: Which of the following options can be used to  make access control decisions in the code using API calls
Options:
  1, Java Authentication and Authorization Service
  2, Programmatic access control
  3, Declarative access control
  4, EJB container
Answer: 2
Marks: 2

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

SNo: 30
Ques: Which of the following statements is true regarding Java Authentication and Authorization Service (JAAS)
Options:
  1, JAAS cannot extend the access control architecture of the Java platform to support user-based authorization.
  2, JAAS enables services to authenticate and enforce access controls upon users.
  3, JAAS does not implement a Java technology version of the standard Pluggable Authentication Module (PAM) framework.
  4, JAAS specifies the implementation of a transaction manager.
Answer: 2
Marks: 2

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

SNo: 31
Ques: Which of the following options will enable you to inform the container not to persist a field or property of the entity class
Options:
  1, LOB annotation
  2, Transient annotation
  3, Table annotation
  4, Basic annotation
Answer: 2
Marks: 2

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

SNo: 32
Ques: Which of the following options provides good support for polymorphic relationships between entities and for queries that range over the class hierarchy
Options:
  1, Single table per class hierarchy strategy
  2, Table per class strategy
  3, Embeddable class
  4, Embedded class
Answer: 1
Marks: 2

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

SNo: 33
Ques: Which of the following options is correct about FROM clause
Options:
  1, The FROM clause specifies the search domain in the persistence tier.
  2, The FROM clause specifies the search domain in the User tier.
  3, The FROM clause is specified using only one path expression.
  4, The FROM clause enables the aggregation of values according to the properties of an entity class.
Answer: 1
Marks: 2

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

SNo: 34
Ques: Which of the following options associates a variable with a persistence entity or a persisted field of a persistence entity
Options:
  1, Path expression
  2, The SELECT statement
  3, The BULK UPDATE statement
  4, JOINS
Answer: 1
Marks: 2

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

SNo: 35
Ques: Which of the following options will enable you to assign a value to the named parameter, say Employee
Options:
  1, createQuery method
  2, createNativeQuery method
  3, setParameter method
  4, NamedQuery annotation
Answer: 3
Marks: 2

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

SNo: 36
Ques: Which of the following clause will you use to specify which persistence entities should be queried by the SELECT query
Options:
  1, FROM clause
  2, WHERE clause
  3, GROUP BY clause
  4, HAVING clause
Answer: 1
Marks: 2

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

SNo: 37
Ques: What will be the sequence of execution of the clauses in a query that contains the following three clauses:
1. GROUP BY clause
2. WHERE clause
3. HAVING clause
Options:
  1, WHERE-->GROUP BY-->HAVING
  2, GROUP BY-->HAVING-->WHERE
  3, WHERE-->GROUP BY
HAVING clause is not included when there is a WHERE clause in the SELECT query
  4, GROUP BY-->WHERE-->HAVING
Answer: 1
Marks: 2

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

SNo: 38
Ques: Which of the following options is true about asynchronous consumer clients
Options:
  1, Asynchronous consumer clients register with the message destination.
  2, Asynchronous consumer clients cannot register with the message destination.
  3, Asynchronous message consumer clients collect messages from the destination.
  4, If the destination is empty, the asynchronous client is blocked until a message arrives.
Answer: 1
Marks: 2

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

SNo: 39
Ques: Which message type will you use to define the set of name-value pairs
Options:
  1, TextMessage
  2, MapMessage
  3, BytesMessage
  4, ObjectMessage
Answer: 2
Marks: 2

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

SNo: 40
Ques: Which of the following options is true about point-to-point messaging architecture
Options:
  1, It is based on the concept of message topic.
  2, In this type of architecture, receiver gets all the messages that were sent to the queue, including those sent before the creation of the receiver.
  3, There is a timing dependency in point-to-point architecture.
  4, In this type of architecture, receiver gets all the messages that were sent to the queue, excluding those sent before the creation of the receiver.
Answer: 2
Marks: 2

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

SNo: 41
Ques: Which of the following objects provides a single-threaded context for producing and consuming messages
Options:
  1, QueueReceiver object
  2, Session object
  3, MessageListener object
  4, Connection object
Answer: 2
Marks: 2

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

SNo: 42
Ques: Which of the following objects enables the JMS API to register a MessageListener object with the queue destination
Options:
  1, Session object
  2, Connection object
  3, QueueReceiver object
  4, QueueConnectionFactory
Answer: 3
Marks: 2

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

SNo: 43
Ques: Which of the following life-cycle events occurs when the container restores the state of the instance to primary storage, from the previously cached secondary storage
Options:
  1, PreRemove
  2, PostActivate
  3, PreDestroy
  4, PostRemove
Answer: 2
Marks: 2

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

SNo: 44
Ques: Which of the following life-cycle events occurs when the container decides to remove the stateful session bean instance from primary storage and cache it in secondary storage
Options:
  1, PostActivate
  2, PostRemove
  3, PrePassivate
  4, PreRemove
Answer: 3
Marks: 2

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

SNo: 45
Ques: Which of the following options is true regarding the life-cycle callback interceptor methods
Options:
  1, The life-cycle callback interceptor methods can throw only remote exceptions.
  2, A life-cycle interceptor method can be annotated to handle only one life-cycle event.
  3, The life-cycle callback interceptor method can be final.
  4, The life-cycle callback interceptor method cannot be static or final.
Answer: 4
Marks: 2

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

SNo: 46
Ques: Which of the following life-cycle event is invoked before a query result is returned or accessed
Options:
  1, PrePersist callback
  2, PostPersist callback
  3, PostLoad callback
  4, PostUpdate callback
Answer: 3
Marks: 2

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

SNo: 47
Ques: Identify the correct rule regarding the callback methods.
Options:
  1, A callback method cannot access entries in the entity class environment.
  2, The same callback method cannot be designated to handle multiple callback events.
  3, Callback methods cannot throw runtime exceptions.
  4, Callback methods must not throw checked exceptions, but can throw unchecked exceptions.
Answer: 4
Marks: 2

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

SNo: 48
Ques: Which of the following CMT transaction attributes is applicable for methods that must execute in a transaction but not necessarily a new transaction
Options:
  1, SUPPORTS
  2, REQUIRES_NEW
  3, NOT_SUPPORTED
  4, REQUIRED
Answer: 4
Marks: 2

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

SNo: 49
Ques: Which of the following CMT transaction attributes defines that a method will execute in the same transaction if it is called with the calling thread currently in a transaction
Options:
  1, REQUIRED
  2, REQUIRES_NEW
  3, SUPPORTS
  4, NOT_SUPPORTED
Answer: 3
Marks: 2

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

SNo: 50
Ques: Which of the following interfaces provides the session bean with the feedback  about the transaction demarcation events
Options:
  1, SessionSynchronization
  2, javax.transaction.UserTransaction
  3, javax.ejb.TimedObject
  4, TimerService
Answer: 1
Marks: 2



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



SNo: 76
Ques: Michael is implementing a banking site. He has created a session bean namely, the SavingAccount and added a method the validateClient. He wants that this method should always run in the client's context. Which of the following transaction attribute will help Michael to achieve this?
Options:
  ? 1,Michael can use the REQUIRES_NEW attribute.
  ? 2,Michael can use the REQUIRED attribute.
  ? 3,Michael can use the SUPPORTS attribute.
  ? 4,Michael can use the MANDATORY attribute.
Answer: 4
Marks: 3

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

SNo: 77
Ques: Samuel is implementing a banking site. He has created a session bean namely, the SavingAccount and added a createNewAccount method to create a new account. He wants that this method should rollback the transaction if any error occurs while creating the user. In such a case, which of the following methods can be used to rollback the transaction attributes?
Options:
  ? 1,The setRollbackOnly method can be called on the transaction to set the flag so that it can be rollbacked once the method returns.
  ? 2,The getRollbackOnly method can be called on the transaction to set the flag so that it can be rollbacked once the method returns.
  ? 3,The setRollback method can be called on the transaction to set the flag so that it can be rollbacked once the method returns.
  ? 4,The rollBack method can be called on the transaction to set the flag so that it can be rollbacked once the method returns.
Answer: 1
Marks: 3

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

SNo: 78
Ques: Matt is implementing a human resources management site. He has created a Employee stateful session bean and added a processHike(double arg) method to process the salary hike of an employee. This method updates employee record in the database with the increased salary and also updates the salary field of the bean. Matt wants to listen to transaction events so that if the transaction is rolledback outside the processHike method's scope the salary field in the employee bean can be updated back to the original value. Which of the following options can Matt use to listen to transaction events?
Options:
  ? 1,Matt can listen to transaction events by implementing SessionSynchronization interface in the employee bean, so that the bean can get notifications depending upon the state of the transaction.
  ? 2,Matt cannot listen to transaction events as it is not possible to listen to the transaction from a stateful session bean.
  ? 3,Matt can by default listen to transaction events without any extra efforts as stateful session beans by default are notified with transaction states
  ? 4,Matt cannot listen to transaction events as it is possible to listen to the transaction only from a stateless session bean and not from a stateful session bean.
Answer: 1
Marks: 3

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

SNo: 79
Ques: You are implementing a human resource site. You have created two entity beans named Employee and Person, which has createEmployee and createPerson methods respectively. The createEmployee methods calls createPerson method to create a person record for an employee. You want that the Employee bean should use Manager role while calling the Person bean's method. Identify which of the following options meets this requirement.
Options:
  ? 1,Yes, a run-as annotation can be used to associate a run-as identity to a bean's method.
  ? 2,Yes, a run-as element in deployment descriptor can be added to associate a run-as identity to a bean's method.
  ? 3,No, it is not possible to specify a different identity when a bean method calls another bean's methods.
  ? 4,Yes, a use-caller-identity element in deployment descriptor can be used to associate a run-as identity to a bean's method.
Answer: 2
Marks: 3

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

SNo: 80
Ques: You have a stateless session bean, the AccountBean which has two methods createAccount and debitAccount. The createAccount method should be executed only by a user with the SYSTEM_ADMINISTRATOR role whereas the debitAccount can be executed by a user with ACCOUNT_MANAGER and SYSTEM_ADMINISTRATOR role. What should be the security implementation for the AccountBean?
Options:
  ? 1,@Stateless @RolesAllowed("SYSTEM_ADMINISTRATOR")
public class AccountBean implements Account{
    public int createAccount() {?}
    public void debitAccount(double value) {?}
}
  ? 2,@Stateless @RolesAllowed({"SYSTEM_ADMINISTRATOR","ACCOUNT_MANAGER"})
public class AccountBean implements Account{
    public int createAccount() {?}
    public void debitAccount(double value) {?}
}
  ? 3,@Stateless
public class AccountBean implements Account{
    @RolesAllowed({"SYSTEM_ADMINISTRATOR","ACCOUNT_MANAGER"})
    public int createAccount() {?}
    @RolesAllowed({"SYSTEM_ADMINISTRATOR","ACCOUNT_MANAGER"})
    public void debitAccount(double value) {?}
}
  ? 4,@Stateless
public class AccountBean implements Account{
    @RolesAllowed("SYSTEM_ADMINISTRATOR")
    public int createAccount() {…}
    @RolesAllowed({"SYSTEM_ADMINISTRATOR","ACCOUNT_MANAGER"})
    public void debitAccount(double value) {…}
}
Answer: 4
Marks: 3

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

SNo: 81
Ques: Simon is implementing a Job site and has been entrusted with the task of sending a notification to all the users, whose password has expired. To meet this requirement, Simon plans to create a named query using the NamedQuery metadata annotation, to fetch all such user records. The USERS table has USER_ID, USER_NAME, PASSWORD, PASSWORD_EXPIRY_DATE columns and the entity bean created for this table is Users with the fields userId, userName, password, and passwordExpiryDate. Which of the following options will Simon use to create this named query?
Options:
  ? 1,@NamedQuery(name = "findExpiredUsers", query = "select OBJECT(u) FROM Users u WHERE u.passwordExpiryDate is not null and passwordExpiryDate <= :passwordExpiryDate")
  ? 2,@NamedQuery(name = "findExpiredUsers", query = "select OBJECT(u) FROM Users u WHERE u.passwordExpiryDate is not null)
  ? 3,entityManager.createQuery
("select OBJECT(u) FROM Users u WHERE u.passwordExpiryDate is not null "+
" and passwordExpiryDate <= :passwordExpiryDate");
  ? 4,entityManager.createNativeQuery
("SELECT OBJECT(u) FROM Users u WHERE u.passwordExpiryDate is not null "+
" and passwordExpiryDate <= :passwordExpiryDate");
Answer: 1
Marks: 3

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

SNo: 82
Ques: Sam is implementing a banking site and has created a SavingAccount entity bean for the SAVING_ACCOUNT table. The SavingAccount bean has a validateAccount method, which validates the account data before committing it to the database. The validateAccount method is coded in such a way that if the data is invalid it throws an application exception. While testing the SavingAccount bean Sam found out that even though the application exception is thrown the container does not rollback the transaction. Sam expected that the container would rollback the transaction if the exception is thrown. Which of the following options can be used rectify this unexpected behavior?
Options:
  ? 1,You can rectify this unexpected behavior by modifying the existing application exception with @ApplicationException(rollback=true) annotation to indicate that container needs to rollback the transaction if this exception is thrown.
  ? 2,You can rectify this unexpected behavior by changing the code to throw a SQLException.
  ? 3,You can rectify this unexpected behavior by changing the code to throw a IOException.
  ? 4,You can rectify this unexpected behavior by modifying the existing application exception with @ApplicationException(onErrorRollback=true) annotation to indicate that container needs to rollback the transaction if this exception is thrown.
Answer: 1
Marks: 3

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

SNo: 83
Ques: Nancy is implementing a social networking site. She has created a Person entity bean for the PERSON table which is used to store the person information. There is a setDateOfBirth(String) method in the entity bean which accepts dates as Strings in dd-mm-yyyy format and converts them to java.util.Date using a date formatter. The date formatter used in the method throws ParseException that should be catched. Nancy wants that if a date string is passed in a wrong format the caller should get an exception. As this condition is non-fatal the transaction should not be rollbacked. Which of the following options she will choose for her catch block to correctly implement her requirement?
Options:
  ? 1,She will catch the ParseException and will not throw any exception in the catch block.
  ? 2,She will catch the ParseException and will throw again a ParseException error in the catch block.
  ? 3,She will catch the ParseException and will throw a wrapper system exception in the catch block.
  ? 4,She will catch the ParseException and will throw a wrapper application exception in the catch block.
Answer: 4
Marks: 3

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

SNo: 84
Ques: Mira is working on banking site and has created a SavingAccount entity bean for the SAVING_ACCOUNT table. However, Mira's code is giving unexpected results and she asks Wendy to review her code of the SavingAccount bean. Wendy on observation finds that the updateAccount method throwing java.rmi.RemoteException to indicate a catastrophic error. How will Wendy rectify Mira's code?
Options:
  ? 1,Wendy does not need to rectify anything because RemoteException is a valid exception and developers can throw this error from an entity bean.
  ? 2,Wendy will change the code to throw EJBException instead of the RemoteException.
  ? 3,Wendy will change the code to throw an application exception instead of the RemoteException.
  ? 4,Wendy will change the code to throw OutOfMemoryError instead of the RemoteException.
Answer: 2
Marks: 3

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

SNo: 85
Ques: You are implementing a human resource site. You have created the following named query to fetch names of all the employees along with the name of their manager.
SELECT e.name, m.name FROM Employee e JOIN Manager m WHERE e.managerId = m.managerId
The Employee record is stored in the EMPLOYEE table and the Manager record is stored in the MANAGER table. Primary key column for EMPLOYEE table is EMPLOYEE_ID and primary key column for MANAGER table is MANAGER_ID. MANGER_ID column in the EMPLOYEE table references MANAGER_ID column in the MANAGER table. This site was using a MySQL database till now but now the client wants to move to an Oracle database. In such a case, observe the preceding query and identify whether you need to make any changes to it? If yes how?

Options:
  ? 1,Yes, you will have to make changes as the Oracle database does not support JOIN keyword and the following changes will need to be made to the query.
SELECT e.name,m.name FROM Employee e,Manager m WHERE e.managerId = m.managerId
  ? 2,Yes, you will have to make changes as the Oracle database is case sensitive and the following changes will need to be made to the query.
select e.name,m.name from Employee e join Manager m where e.managerId = m.managerId
  ? 3,Yes, you will have to make changes as the Oracle database is case sensitive and does not support the JOIN keyword. Therefore, the following changes will need to be made to the query.
select e.name,m.name from Employee e, Manager m where e.managerId = m.managerId
  ? 4,No, you will not have to make any changes as named queries created using Java Persistence Query language are database independent and need not be changed while changing the database server vendor.
Answer: 4
Marks: 3

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

SNo: 86
Ques: You have been entrusted with the task of creating an indexing module for a job site. This module will create indexes of the resumes uploaded by the candidates during registration. These indexes need to be created for better and faster search results. Identify which of the following techniques will you use to develop this module?


Options:
  ? 1,You will create a normal class file which will be called during the registration flow while uploading the resumes to create indexes on the fly.
  ? 2,You will create a Message-driven bean which will perform the indexing job and modify the resume uploading code so that it creates a index as soon as a resume is uploaded.
  ? 3,You will create a timer program which will be scheduled to run daily in the night. This program will look for all the newly uploaded resumes and create indexes for them.
  ? 4,You will create a Java standalone program which will be called manually by the system administrator to create indexes when required.
Answer: 2
Marks: 3

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

SNo: 87
Ques: Sam is implementing a banking site. He has created a session bean, User which produces messages that are consumed synchronously by entity bean namely SavingAccount. The messages are consumed synchronously so till the SavingAccount bean finishes processing the messages server resources remains locked. Which of the following options can Sam use to optimize the use of resources?
Options:
  ? 1,Create a message driven bean to process the messages instead of SavingAccount bean.
  ? 2,Upgrade the server so that it has ample resources.
  ? 3,Instead of Java EE use some other architecture that allows asynchronous message consumers.
  ? 4,Messages can only be processed synchronously, so nothing can be done in this scenario.
Answer: 1
Marks: 3

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

SNo: 88
Ques: Sam is using IBM's WebSphere application server for his Java EE based banking site. WebSphere provides special APIs for logging and transaction controls that generates non-JMS messages. Sam wants to use these APIs and non-JMS messages in his application. Can he use non-JMS messages in his application and how?



Options:
  ? 1,Yes, Sam can use non-JMS messages, he can make use of non-JMS message driven bean for non-JMS messages.
  ? 2,Yes, Sam can use non-JMS messages, he can make use of JMS message driven bean for non-JMS messages.
  ? 3,No, Sam cannot use non-JMS messages, as Java EE architecture does not provide support for non-JMS messages.
  ? 4,No, Sam cannot use non-JMS messages, as it requires Java Native Interface to access non-JMS messages and it is not recommended to use JNI from EJBs.
Answer: 1
Marks: 3

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

SNo: 89
Ques: Sam is using JMS message driven bean for his social networking site. Message produces TextMessages that can be of type NormalText or HTMLText. He is using BlogMessageClient bean to handle these blog messages. To identify whether the object of the BlogMessageClient can handle NormalText or HTMLText, he has added a type field to the class. To initialize this field he has added a initializeType() method. He wants that this method should be called immediately after initialization of the bean. For which of the following events he will create the method as a handler?
Options:
  ? 1,For PostConstruct event he will create initializeType() as a handler.
  ? 2,For PreDestroy event he will create initializeType() as a handler.
  ? 3,For PostActivate event he will create initializeType() as a handler.
  ? 4,For PrePassivate event he will create initializeType() as a handler.
Answer: 1
Marks: 3

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

SNo: 90
Ques: You have just finished creating a JMS message driven 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,Overide the finalize method in the bean class and deallocate the resources in that method.
  ? 2,Create a method to handle the PreDestroy life-cycle event of the bean and in this method deallocate the resources.
  ? 3,Create a method to handle the PrePassivate life-cycle event of the bean and in this method deallocate the resources.
  ? 4,Nothing can be done for the issue so you will restart the server each time the Application Server is low on resources.
Answer: 2
Marks: 3

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

SNo: 91
Ques: Ryan has created a stateless session bean, named BankingBean, which includes the endBanking method as a handler for PrePassivate event. However, the endBanking method, which should be executed during the lifecycle of the bean, never gets called. Observe the partial code given below and identify the reason for this unexpected result.

@Stateless public class BankingBean implements Banking {
public int someMethod(){...};
//...
@PrePassivate private void endBanking() {...};
}


Options:
  ? 1,The endBanking method is called but endBanking method throws a runtime exception and so container does not execute the method.
  ? 2,The endBanking method is not called because stateless beans do not fire PrePassivate life-cycle events.
  ? 3,The endBanking method is not called because the handle is not created properly. The name of the handler is not passed as a parameter such as, @PrePassivate{"EndBankingHanlde"}
  ? 4,The endBanking method is not called because passivation of a stateless session bean is very unpredictable.
Answer: 2
Marks: 4

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

SNo: 92
Ques: You have a stateful session bean, named as ShoppingCartBean, for which you have created an activateBean method to initialize the bean and generate a unique ID for the shopping cart. You now have to create a code to ensure that the activateBean method is executed on creation and activation of the bean. Which of the following codes will help in the preceding task?
Options:
  ? 1,@PostActivate
@PostConstruct
private void activateBean() {...};
  ? 2,@PostActivate,PostConstruct
private void activateBean() {...};
  ? 3,@PostActivate
private void activateBean() {...};
@PostConstruct
private void activateBean() {...};
  ? 4,@{PostActivate,PostConstruct}
private void activateBean() {...};
Answer: 1
Marks: 4

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

SNo: 93
Ques: You have created a session bean, namely UserBean by using the following code snippet:

@Stateless
public final class UserBean implements UserInterface{
public boolean validateLogin(String userName, String password){//code to validate login and return a boolean value}
}

While compiling the bean you are getting an error. Identify what is the issue with the preceding code?
Options:
  ? 1,A final keyword cannot be used while defining a session bean.
  ? 2,A default constructor should be defined while defining a session bean.
  ? 3,A session bean class should not implement interfaces.
  ? 4,A session bean should always be an abstract class.
Answer: 1
Marks: 4

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

SNo: 94
Ques: You have created a session bean, with a stateless annotation. However, you have also added the following entry for the bean in the deployment descriptor.

<session-type>Stateful</session-type>

Which of the following issues will arise in this situation?
Options:
  ? 1,This situation will cause a runtime exception because structural information provided as annotations should not be overridden in the deployment descriptor.
  ? 2,This situation will not cause any issues because the container will ignore the deployment descriptor entry.
  ? 3,This situation will not cause any issues because the container will ignore the annotations entry.
  ? 4,This situation will not cause any issues because the deployment descriptor's entry will override the annotation's entry.
Answer: 1
Marks: 4

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

SNo: 95
Ques: You have created a session bean, using stateless annotations. However, when you try to compile this session bean it gives you a compile error. You have JDK1.4.2 installed in your machine. Which of the following options do you think is the reason for this error?
Options:
  ? 1,You get a compile error because for compiling session bean java files, you should first install Java EE 5 SDK.
  ? 2,You get a compile error because JDK1.4.2 does not support annotations and you should at least have JDK1.5.0 installed. Annotations were only introduced with JDK1.5.0.
  ? 3,You get a compile error because for compiling session bean java files, you should first install an Application Server like Sun Java? System Application Server.
  ? 4,You get a compile error because the installation of JDK1.4.2 on your machine is corrupt, causing it to behave unexpectedly.
Answer: 1
Marks: 4

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

SNo: 96
Ques: Billy is using following code for his message driven bean:
@MessageDriven(messageListenerInterface=javax.jms.MessageListener.class,
mappedName = "jms/MessageDrivenBean")
public class MessageDrivenBean{
    public void onMessage(Message message) {//some code}
    @PostConstruct void obtainResource() throws CustomApplicationException{//some code}
    @PreDestroy void releaseResource() throws CustomApplicationException {//some code}
}
Please verify the preceding code to rectify if it contains any issues?
Options:
  ? 1,The above code does not have any issues and will successfully create a message driven bean namely MessageDrivenBean.
  ? 2,MessageDrivenBean is not implementing the MessageListener interface and so when container tries to notify the bean with the message a run time exception will be thrown.
  ? 3,MessageDrivenBean is not explicitly implementing the default constructor and so when container tries to notify the bean with the message a run time exception will be thrown.
  ? 4,It is not recommended that life-cycle event handler methods should throw application exceptions. So the throws clause should be removed.
Answer: 4
Marks: 4

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

SNo: 97
Ques: Billy is using following code for his message driven bean:
@MessageDriven(messageListenerInterface=javax.jms.MessageListener.class,
               mappedName = "jms/MessageDrivenBean",
               activationConfig =  {
               @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Client-acknowledge"),
               @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
               })
public class MessageDrivenBean{
    public void onMessage(Message message) {//some code}
}
But he is facing a runtime exception with the above code. Please verify the preceding code to rectify if it contains any issues?
Options:
  ? 1,MessageDrivenBean is not implementing the MessageListener interface and so when container tries to notify the bean with the message a run time exception is thrown.
  ? 2,Improper value for property acknowledgeMode is specified in the ActivationConfigProperty annotation and so when container tries to set this value a run time exception is thrown.
  ? 3,MessageDrivenBean is not explicitly implementing the default constructor and so when container tries to notify the bean with the message a run time exception is thrown.
  ? 4,There is no issue with the code, the runtime exception is occurring because of some configuration issue with the server.
Answer: 2
Marks: 4

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

SNo: 98
Ques: Billy is using following code for his message driven bean:

@MessageDriven(messageListenerInterface=javax.jms.MessageListener.class,
mappedName = "jms/MessageDrivenBean")
public final class MessageDrivenBean{
    public void onMessage(Message message) {//some code}
}

Please verify the preceding code to rectify if it contains any issues?
Options:
  ? 1,The above code does not have any issues and will successfully create a message driven bean namely MessageDrivenBean.
  ? 2,MessageDrivenBean is not implementing the MessageListener interface and so when container tries to notify the bean with the message a run time exception will be thrown.
  ? 3,MessageDrivenBean is not explicitly implementing the default constructor and so when container tries to notify the bean with the message a run time exception will be thrown.
  ? 4,It is not recommended that the JMS message driven beans be created as final classes. So the final keyword should be removed.
Answer: 4
Marks: 4

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

SNo: 99
Ques: Charlie is implementing a human resources management site and has created an Employee stateless session bean. He wants to listen to transaction events and has therefore added the necessary methods to the bean. The following code snippet displays the beans and the methods:
@Stateless
public class EmployeeBean implements Employee, SessionSynchronization{
    @TransactionAttribute(TransactionAttributeType.MANDATORY)
    public void processPayroll(){//some code}
     public void afterCompletion(boolean committed){...}
    public void afterBegin(){...}
    public void beforeCompletion(){...}
}
However, while compiling his bean he is getting a compilation error. Identify the reason for this unexpected result?
Options:
  ? 1,Charlie is getting the compiler error, because stateless session beans cannot implement SessionSynchronization interface.
  ? 2,Charlie is getting the compiler error, because he has not defined the TransactionManagement annotation.
  ? 3,Charlie is getting the compiler error, because TransactionAttributeType.MANDATORY is not a valid transaction attribute type for a stateless session bean.
  ? 4,Charlie is getting the compiler error, because he has not defined the default constructor for the bean.
Answer: 1
Marks: 4

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

SNo: 100
Ques: Rick is implementing a human resources management site and has created an Employee stateless session bean and added method createNewEmployee to the bean. He is using BMT for transaction demarcation and wants that whenever the createNewEmployee is called it should be called in a new transaction. The following code snippet displays the beans and the methods:
@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class EmployeeBean implements Employee{
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public void createNewEmployee(){
    //code to verify if the transaction is new
    //some more code
    }
}
However, when this bean is executed and createNewEmployee method is called he finds that the method is not called within a new transaction. What could be the reason for this unexpected result?
Options:
  ? 1,Rick is getting this unexpected result because he is using a wrong transaction attribute type i.e. REQUIRES_NEW, instead REQUIRED should be used.
  ? 2,Rick is getting this unexpected result because stateless beans do not support transaction demarcation. As a result, all the methods are called in the same transaction.
  ? 3,Rick is getting this unexpected result because stateless beans do not support BMT. Therefore, all the methods are called in the same transaction.
  ? 4,Rick is getting this unexpected result because he is using BMT because of which the container does not manage the transactions for the bean, it should be managed programmatically.
Answer: 4
Marks: 4



SNo: 101
Ques: Billy is using following code for his message driven bean:
@MessageDriven(mappedName = "jms/NewMessage", activationConfig =  {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
@TransactionManagement(TransactionManagementType.CONTAINER)
public class MessageDrivenBean implements MessageListener {
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void onMessage(Message msg){ }
}
You have specified REQUIRED as transaction attribute type but unexpectedly even though if there is an active transaction, when the onMessage method is called, it is always executed in a new transaction. Identify the reason for this unexpected result.
Options:
  1,Message driven beans are always called in a new transaction if the transaction attribute type is REQUIRED.
  2,Message driven beans are always called in a new transaction when CMT is used no matter what type of the transaction attribute type is specified.
  3,Message driven beans are always called in a new transaction no matter if CMT or BMT is used.
  4,REQUIRED transaction attribute indicates that the bean should always be called in a new transaction, so if instead of message driven bean any other bean was used the method would have been called in a new transaction.
Answer: 1
Marks: 4

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

SNo: 102
Ques: Billy is using following code for his message driven bean:

@MessageDriven(mappedName="jms/MessageQueue")
public class MessageDrivenBean implements MessageListener {
  public void onMessage(Message msg) {//code for message processing}
  public void finalize(){//some processing}
}

Please verify the preceding code to rectify if it contains any issues
Options:
  1,The above code does not have any issues and will successfully create a message driven bean namely MessageDrivenBean.
  2,@MessageDriven annotation only defines mappedName property, messageListenerInterface attribute should also be specified.
  3,finalize() method is a protected message in Object class so it cannot be public in the MessageDrivenBean class.
  4,It is not recommended that message driven bean should implement the finalize method. So the finalize method should be removed.
Answer: 4
Marks: 4

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

SNo: 103
Ques: Billy is using following code for his message driven bean:
@MessageDriven(mappedName="jms/MessageQueue",
                         messageListenerInterface=javax.jms.MessageListener.class)
public class MessageDrivenBean {
  public void onMessage(TextMessage msg) {//code for message processing}
}
But at times he is facing a runtime exception. Please verify the preceding code to rectify if it contains any issues
Options:
  1,MessageDrivenBean is not implementing the MessageListener interface and so when container tries to notify the bean with the message a run time exception is thrown.
  2,MessageDrivenBean is not implementing the onMessage(Message) method and so when container tries to notify the bean with any other type of message(ObjectMessage,MapMessage etc.) a run time exception is thrown.
  3,MessageDrivenBean is not explicitly implementing the default constructor and so when container tries to notify the bean with the message a run time exception is thrown.
  4,There is no issue with the code, the runtime exception is occurring because of some configuration issue with the server.
Answer: 2
Marks: 4

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

SNo: 104
Ques: Billy is using the following code to create a asynchronous message driven bean:

@MessageDriven(mappedName = "jms/MessageDrivenBean", activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable"),
@ActivationConfigProperty(propertyName = "clientId", propertyValue = "MessageDrivenBean"),
@ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "MessageDrivenBean")
})
@TransactionManagement(TransactionManagementType.CONTAINER)
public class MessageDrivenBean implements MessageListener {
public void onMessage(Message msg){ }
}

While executing the onMessage method, if an exception is thrown, you have specified to rollback the transaction. But this is resulting in an endless loop. What could be the possible reason for the same


Options:
  1,When the onMessage method of message driven bean fails the container tries to rectify the issue by calling the onMessage method again. But, the onMessage method fails again and again as the message has an error eventually causing an end-less loop.
  2,When Auto-acknowledge, is used the container tries to notify the message driven bean of the error by calling the onMessage method. But, the onMessage method fails again and again as the message has an error and container will again try to notify the bean using onMessage method eventually causing an end-less loop.
  3,When javax.jms.Topic is used as a destination type, the container tries to resend all the unprocessed messages by calling the onMessage method. But, the onMessage method fails again, as the message has an error and the messages remain unprocessed. The container will continue to call the onMessage method eventually causing an end-less loop.
  4,When a transaction is rollbacked the message is again delivered to the message driven bean. However, the onMessage method will fail again as the message has an error which will again rollback the transaction, eventually causing an endless loop.
Answer: 4
Marks: 4

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

SNo: 105
Ques: You are implementing a banking site for which you have created the SavingAccount entity bean for manipulating the saving bank accounts. You have created three methods in the bean, the createAccount for creating account, the closeAccount for closing account and the updateAccount for updating account. The bean methods can be called from any roles SysAdmin, Manager or Guest i.e. the container should not check the security of the bean methods. You are using the following code snippet in your deployment descriptor file to achieve this:
<method-permission>
<role-name>*</role-name>
<method>
<ejb-name>SavingAccountBean</ejb-name>
<method-name>*</method-name>
</method>
</method-permission>
Even though you are calling the bean from SysAdmin role the container is not executing the bean methods. Identify the error in the preceding code.
Options:
  1,This is not a valid way to indicate that the bean can be executed from any role, instead unchecked element should be used in the method-permission element.
  2,The method-permission element in the deployment descriptor specifies the roles which are not allowed, so the above code tells container not to allow any role.
  3,The deployment descriptor does not indicate which type of bean for which the  security is enforced, so container disallows all the roles.
  4,The * is used as method name so as per the method-permission tag it'll allow the method whose name is * and as none of the methods are named * the container blocks all the calls.
Answer: 1
Marks: 4

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

SNo: 106
Ques: Which of the following options in a Java EE Application Environment does not contain the exception handling code
Options:
  1, Enterprise bean method
  2, Container
  3, Enterprise bean client
  4, Naming Service
Answer: 4
Marks: 1

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

SNo: 107
Ques: How can you rollback a transaction when an exception is thrown
Options:
  1, Setting the rollback value of the ApplicationException annotation to true.
  2, Setting the rollback value of the CreateException to true.
  3, Setting the rollback value of the RemoteException to true.
  4, Setting the rollback value of the ObjectNotFoundException to true.
Answer: 1
Marks: 1

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

SNo: 108
Ques: Which of the following interfaces' method is used to check the rollback status of the transaction
Options:
  1, javax.transaction.UserTransaction interface.
  2, javax.ejb.TimedObject interface
  3, javax.resource.ResourceException interface
  4, javax.resources.cci interface
Answer: 1
Marks: 1

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

SNo: 109
Ques: Which of the following methods is used to create a query object
Options:
  1, createNamedQuery
  2, createQuery
  3, createNativeQuery
  4, createdQuery
Answer: 2
Marks: 1

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

SNo: 110
Ques: Which of the following options will you use in a bean client code to determine the state of the client transaction
Options:
  1, UserTransaction.getStatus method
  2, setParameter method
  3, getBeanStatus method
  4, setRollbackOnly method
Answer: 1
Marks: 1

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

SNo: 111
Ques: Which of the following exceptions is defined in the throws clause of the enterprise bean business interfaces or in a message listener interface
Options:
  1, RemoteException
  2, Application exception
  3, EJBException
  4, RuntimeException
Answer: 2
Marks: 2

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

SNo: 112
Ques: In which of the following tiers the exceptions can be caused by an error in the underlying data resource, such as the inability to establish a database connection
Options:
  1, Client tier
  2, Client-to-application server tier
  3, EIS tier
  4, Application server tier
Answer: 3
Marks: 2

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

SNo: 113
Ques: Which of the following areas defines an exception caused by errors in the services supplied to the enterprise bean by the Java EE technology container
Options:
  1, The EIS tier
  2, The client-to-application server tier infrastructure
  3, The client tier
  4, The application server tier
Answer: 4
Marks: 2

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

SNo: 114
Ques: Which of the following options will you use to deal with the situation that may effect the data integrity and, in addition, a transaction rollback occurs
Options:
  1, Call the setRollbackOnly method and throw an application exception
  2, Call the setRollbackOnly method and throw a RuntimeException
  3, Call the setRollbackOnly method and throw an EJBException
  4, Call the setRollbackOnly method and throw a RemoteException
Answer: 1
Marks: 2

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

SNo: 115
Ques: Which of the following transactions indicates that a method requiring a transaction context has been invoked without the required transaction context
Options:
  1, Transaction-rollback exception
  2, Transaction-required exception
  3, EJBException
  4, RemoteException
Answer: 2
Marks: 2

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

SNo: 116
Ques: Which of the following beans must directly or indirectly implement the javax.jms.MessageListener interface
Options:
  1, JMS messagedriven bean
  2, Stateful Session beans
  3, Non JMS message-driven bean
  4, Entity beans
Answer: 1
Marks: 2

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

SNo: 117
Ques: Which of the following options is correct in reference to the Message-driven beans
Options:
  1, Message-driven beans have remote component and local component interfaces.
  2, Message-driven beans provide Java EE components with a direct interface.
  3, Message-driven beans have no client-visible identity.
  4, Message-driven beans are not anonymous to clients.
Answer: 3
Marks: 2

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

SNo: 118
Ques: Which of the following options is correct in reference to the callback method in a message driven bean (MDB)
Options:
  1, It can have any type of access modifier (public, default, protected or private).
  2, It must throw an application exception.
  3, It cannot throw a runtime exception.
  4, It must use dependency injections.
Answer: 1
Marks: 2

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

SNo: 119
Ques: While creating a non-JMS message-driven bean class, which of the following annotations will you use to annotate the message-driven bean class
Options:
  1, MessageDriven metadata annotation
  2, PostCosntruct metadata annotation.
  3, PreDestroy metadata annotation.
  4, Resource metadata annotation
Answer: 1
Marks: 2

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

SNo: 120
Ques: Which of the following statements is true regarding the Non-JMS Message-driven bean class
Options:
  1, The class must be declared public.
  2, The class must be declared final.
  3, The class must be declared abstract.
  4, Define a finalize method.
Answer: 1
Marks: 2

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

SNo: 121
Ques: Which of the following functions can be performed by an enterprise bean by using the timer functionality tasks
Options:
  1, Interrogate a timer callback notification object.
  2, Annotate the method with the Timeout annotation.
  3, Identify the user
  4, Makes the application portable.
Answer: 1
Marks: 2

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

SNo: 122
Ques: Which of the following methods of the Timer class returns a serializable handle to the timer object and  it enables you to obtain a reference to the timer object at a future date
Options:
  1, getTimeRemaining
  2, getHandle
  3, getNextTimeout
  4, getInfo
Answer: 2
Marks: 2

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

SNo: 123
Ques: Which of the following TimerService methods will you use to create an interval timer with an initial relative time-based notification
Options:
  1, createTimer(long initialDuration, long intervalDuration, Serializable info)
  2, createTimer(Date initialExpiration, long intervalDuration, Serializable info)
  3, createTimer(long duration, Serializable info)
  4, createTimer(Date expiration, Serializable info)
Answer: 1
Marks: 2

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

SNo: 124
Ques: Which of the following method signatures is used to define a callback method in the callback listener class
Options:
  1, public void methodName(EntityClassType b)
  2, public void methodName()
  3, public void anyMethodName(InvocationContext ic)
  4, public Object anyMethodName(InvocationContext ic) throws Exception
Answer: 1
Marks: 2

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

SNo: 125
Ques: Which of the following is the correct signature to define a life-cycle callback interceptor method in the interceptor class
Options:
  1, public void methodName()
  2, protected void MethodName(InvocationContext ic)
  3, public Object MethodName(InvocationContext ic) throws Exception
  4, public void methodName(EntityClassType b)
Answer: 2
Marks: 2



SNo: 126
Ques: Which of the following is true regarding the Java EE security
Options:
  1, Contains reference to the real security infrastructure.
  2, Cannot use declarative or programmatic authorization controls
  3, Maps the security policy to the target security domain
  4, Does not provide end-to-end security
Answer: 3
Marks: 2

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

SNo: 127
Ques: Which of the following options can be authenticated by an authentication protocol in a security service, deployed in an enterprise
Options:
  1, Role
  2, Caller
  3, Principal
  4, Resources
Answer: 3
Marks: 2

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

SNo: 128
Ques: Which of the following statements is correct in reference to the principal identity
Options:
  1, A principal does not represent a user in the native security domain.
  2, A principal is an unauthenticated user in the Java EE security domain.
  3, A principal is identified using a principal name and authenticated using authentication data.
  4, A principal has predefined credential requirements associated with it.
Answer: 3
Marks: 2

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

SNo: 129
Ques: Which of the following properties of transaction management allows the data store to handle concurrent transactions and, in addition, ensures that the data integrity is maintained
Options:
  1, Isolation
  2, Durability
  3, Atomicity
  4, Consistency
Answer: 1
Marks: 2

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

SNo: 130
Ques: Which of the following transaction management properties ensures that the individual actions are bundled together and appear as one single unit of work
Options:
  1, Atomicity
  2, Durability
  3, Consistency
  4, Locking
Answer: 1
Marks: 2

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

SNo: 131
Ques: Which of the following options is correct in reference to the Fetch mode settings
Options:
  1, Fetch mode settings are instructions to the persistence provider.
  2, Fetch mode settings are used when the EntityManager API is invoked.
  3, Fetch mode settings is used to Set the value of the mappedBy attribute to the value of the relationship or property in the owning entity.
  4, Fetch mode settings can cause specific entity instance life-cycle events to flow across relationships.
Answer: 1
Marks: 2

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

SNo: 132
Ques: Which of the following mode settings can be defined as a hint to the persistence provider to defer the loading of the association target to the time association target is accessed
Options:
  1, EAGER
  2, REFRESH
  3, LAZY
  4, PERSIST
Answer: 3
Marks: 2

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

SNo: 133
Ques: Which of the following options requires that the columns that correspond to state specific to the subclasses are nullable
Options:
  1, Single table per class hierarchy strategy
  2, Table per class strategy
  3, Joined subclass strategy
  4, strategy attribute of the Inheritance annotation
Answer: 1
Marks: 2

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

SNo: 134
Ques: Which of the following options is true regarding table per class object/relational mapping strategy
Options:
  1, It provides good support for polymorphic relationships.
  2, It requires a common table to represent the root entity class in the hierarchy.
  3, It requires that one or more join operations be performed to instantiate instances of a subclass.
  4, It provides poor support for polymorphic relationships.
Answer: 4
Marks: 2

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

SNo: 135
Ques: Which of the following options is true regarding joined subclass object/relational mapping strategy
Options:
  1, It requires a common table to represent the root entity class in the hierarchy.
  2, It does not provide support for polymorphic relationships between entities.
  3, It requires a table for each concrete class in the hierarchy.
  4, It has a column for each unique persistence field in the hierarchy.
Answer: 1
Marks: 2

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

SNo: 136
Ques: You have been allocated a task to create entity beans for PERSON and PERSON_ASSIGNMENT tables. PERSON table is used to store the person information and PERSON_ASSIGNMENT table is used to store a person's work related information. The cardinality between PERSON and PERSON_ASSIGNMENT table is one-to-many. Apart from cardinality you want that as soon as the PERSON record is removed the corresponding PERSON_ASSIGNMENT record should also be removed. Which of the following options you will use to do so
Options:
  1,@OneToMany(cascade=PERSIST)
  2,@OneToOne(cascade=PERSIST)
  3,@ManyToOne(cascade=PERSIST)
  4,@OneToMany
Answer: 1
Marks: 3

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

SNo: 137
Ques: You have been allocated a task to create entity beans for EMPLOYEE and EMPLOYEE_ASSIGNMENT tables. EMPLOYEE table is used to store the employee information and EMPLOYEE_ASSIGNMENT table is used to store the employee's work related information. The cardinality between EMPLOYEE and EMPLOYEE_ASSIGNMENT table is one-to-many. You want to create Employee and EmployeeAssignment entity beans in such a way that they will follow the cardinality and the related employee assignments are available in the employee entity and vice-versa. What of the following options you will use for this
Options:
  1,Provide OneToMany annotation in the Employee entity bean and ManyToOne annotation in the Employee_Assignment entity bean.
  2,Provide ManyToOne annotation in the Employee entity bean and OneToMany annotation in the Employee_Assignment entity bean.
  3,Provide OneToMany annotation in the Employee entity.
  4,Provide ManyToOne annotation in the Employee_Assignment entity bean.
Answer: 1
Marks: 3

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

SNo: 138
Ques: You have been given the task of creating Person, Employee and ContractEmployee entity beans for a Human Resource Management System's site. Employee and ContractEmployee bean inherits the Person bean. Person records get stored to PERSON table, Employee records get stored to EMPLOYEE table and ContractEmployee record get stored to CONTRACT_EMPLOYEE table in the database. EMPLOYEE and CONTRACT_EMPLOYEE tables store only the extra information which is not present in the PERSON table. Which of the following strategy can be used for implementing the inheritance between these entity beans


Options:
  1,Single table per class hierarchy strategy.
  2,Table per class strategy.
  3,Joined subclass strategy.
  4,Inheritance is not possible in these entity beans.
Answer: 3
Marks: 3

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

SNo: 139
Ques: You have been given the task of creating Person and Employee entity beans for a Human Resource Management System's site. Employee bean class inherits the Person bean class.. Both Person and Employee records get stored to the same table in the database named as PERSON. Which of the following strategy can be used for implementing the inheritance between these entity beans
Options:
  1,Single table per class hierarchy strategy.
  2,Table per class strategy.
  3,Joined subclass strategy.
  4,Inheritance is not possible in these entity beans.
Answer: 1
Marks: 3

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

SNo: 140
Ques: You have been given the task of upgrading an existing Human Resource Management System's (HRMS) site using Java EE architecture. Legacy system was using concrete class Employee for employee information that extends an abstract class Person. You are creating an Employee entity bean for table EMPLOYEE to store the employee information. Employee bean will be a table-based entity. Most of the code is already present in the old Person class and you do not want to redo the job and still want to use the abstract class Person. Identify whether it is possible for an entity bean to extend an abstract class Give a reason.


Options:
  1,No, this is not possible because an entity bean cannot inherit an abstract class.
  2,Yes, it is possible but the Person class should be defined as a MappedSuperclass so that the Employee bean can extend it.
  3,Yes, it is possible but the Person class should also be created as an entity bean and then only the Employee bean can inherit it.
  4,No, this is not possible because entity beans cannot extend any class. Therefore, the Employee bean too cannot extend Person class.
Answer: 2
Marks: 3

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

SNo: 141
Ques: Mary is implementing a banking site for which she has created a stateless session bean namely, the AccountBean. The following code snippet displays the partial code of deployment descriptor file:

<security-role-ref>
  <description> Role for creating account. </description>
  <role-name>SYSTEM_ADMINISTRATOR</role-name>
  <role-link>SystemAdministrator</role-link>
</security-role-ref>

<security-role>
  <description>Allows access to createAccount. </description>
  <role-name>SystemAdministrator</role-name>
</security-role>

<method-permission>
  <role-name>SystemAdministrator</role-name>
  <method>
    <ejb-name>AccountBean</ejb-name>
    <method-name>createAccount</method-name>
  </method>
</method-permission>

In reference to the preceding code, which of the following statements are correct
Options:
  1,The code snippet does not enforce any security, instead annotations should be used.
  2,The code snippet is not well-formed and so it will give a run-time exception.
  3,The code snippet enables security such that the caller with role SYSTEM_ADMINISTRATOR can only execute the createAccount method of AccountBean.
  4,The code snippet enables security such that only the caller with role SystemAdministrator can execute the createAccount method of AccountBean.
Answer: 4
Marks: 3

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

SNo: 142
Ques: You have created a stateless bean namely, the EmployeeBean for a human resource management site. The EmployeeBean uses BMT and has a processPayroll method to process the payroll of the employees. You have a requirement that when the processPayroll method is called from a client's transaction, the method should not commit or rollback the transaction while returning. Is it possible for a stateless session bean to start a transaction and commit or rollback it before the method returns and how
Options:
  1,Yes, SUPPORTS can be used as a transaction attribute type annotation.
  2,Yes, REQUIRED can be used as a transaction attribute type annotation.
  3,Not possible as stateless session bean does not support this type of transaction policy.
  4,Yes, stateless session bean by default support this type of transaction policy.
Answer: 1
Marks: 3

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

SNo: 143
Ques: You have created a stateful bean EmployeeBean for a human resource management site. The EmployeeBean uses BMT and has a processPayroll method to process the payroll of the employee. You want that the processPayroll method should always be executed in a new transaction and the method should not commit or rollback the transaction while returning. Identify whether this is possible and give a reason.
Options:
  1,Yes, it is possible transaction type annotation SUPPORTS can be used for this requirement.
  2,Yes, it is possible transaction type annotation REQUIRED can be used for this requirement.
  3,No, it is not possible as stateful session bean does not support this type of transaction policy.
  4,Yes, it is possible as stateful session bean by default supports this type of transaction policy.
Answer: 4
Marks: 3

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

SNo: 144
Ques: Billy is implementing a social networking site. He has created all the necessary enterprise beans and their configurations. Now he is implementing security for the site. He has been told that there will be following four types roles for this site:

1.guest: who can only view and explore the site.
2. user: who can view, explore and modify the site content.
3.manager: who can modify the site's behavior.
4. system_admin: who will do the configuration steps.

He is been asked to create 3 users one with only guest responsibility, one with user and manager responsibilities, and one with system_admin responsibility. How many principals and roles do you think he needs to create
Options:
  1,4 principals and 3 roles
  2,3 principals and 4 roles
  3,3 principals and 3 roles
  4,12 principals and 12 roles
Answer: 2
Marks: 3

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

SNo: 145
Ques: You are implementing a banking site for which you have created a SavingAccount entity bean for manipulating the saving bank accounts. You have created three methods in the bean, the createAccount for creating an account, the closeAccount for closing an account and the updateAccount for updating an account. All the three methods can be called from SysAdmin and Manager roles. Which of the following annotations is best suited for securing SavingAccount bean
Options:
  1,@Stateless public class SavingAccountBean implements SavingAccount{
@PermitAll
public void createAccount{..}
@PermitAll
public void closeAccount{..}
@PermitAll
public void updateAccount{..}
}
  2,@Stateless
@PermitAll
 public class SavingAccountBean implements SavingAccount{
public void createAccount{..}
public void closeAccount{..}
public void updateAccount{..}
}
  3,@Stateless
@RolesAllowed({"SysAdmin","Manager"})
public class SavingAccountBean implements SavingAccount{
public void createAccount{..}
public void closeAccount{..}
public void updateAccount{..}
}
  4,@Stateless
public class SavingAccountBean implements SavingAccount{
@RolesAllowed({"SysAdmin","Manager"})
public void createAccount{..}
public void closeAccount{..}
public void updateAccount{..}
}
Answer: 3
Marks: 3

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

SNo: 146
Ques: Samuel is implementing a banking site. He has created a stateless session bean namely, the AccountBean, and added a debitAccount method to process debit on an account. He is using BMT for implementing transactions. The following code snippet displays the partial code of the debitAccount method:

 @Stateless @TransactionManagement(BEAN)
public class AccountBean implements Account {
  public void debitAccount(int actNo, double amount) {
    try {  Connection con = dataSource.getConnection();
      userTransaction.begin();
      PreparedStatement pStmt = con.prepareStatement(
      "update ACCOUNT set balance = balance+ where account_number = ");
      prepStmt.setDouble(1, amount);
      prepStmt.setInt(2, actNo);
      int rowCount = pStmt.executeUpdate();
    } catch (Exception ex) {  }
}

Identify the error in the preceding code.
Options:
  1,In the code, TransactionManagement(CONTAINER) should be used as TransactionManagement(BEAN) is incorrect for BMT.
  2,In the code, any transaction started by a stateless session bean must commit or roll back before the method returns.
  3,In the code, there are compilation issues as default constructor is not provided in the bean.
  4,In the code, SQLException is not catched in the catch block so the code will throw a compilation error as SQLException is a checked exception.
Answer: 2
Marks: 4

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

SNo: 147
Ques: You are implementing a human resource site. You have created an Employee session bean whose createEmployee method calls createPerson method of the Person entity bean to create person record for an employee. You want that when the Employee bean is calling the Person bean's method it should call it using Manager role. For this you are using following code snippet in the deployment descriptor:
<enterprise-beans>
  <session>
  <ejb-name>Employee</ejb-name>
  ...
  <security-identity>
    <run-as>
        <role-name>Manager</role-name>
    </run-as>
    <use-caller-identity/>
  </security-identity>
 </session>
</enterprise-beans>

You now have created another method processPayroll in the Employee bean which calls the PayrollBean entity bean's runPayroll method. You expect that the runPayroll bean should not be called with Manager identity as you think that only the createPerson method of Person bean will be called with Manager identity. But unexpectedly the runPayroll method is also called with Manager identity. Identify the reason for this unexpected result
Options:
  1,Run-as identity is associated with a bean and not with its methods specifically, so if any of the bean's method executes another bean's method Manager identity is used.
  2,Use-caller-identity element is also specified in the security identity which enforces that all of the other bean's method should be called with the same identity.
  3,Security-identity element is used in deployment descriptor which can be attached only at bean level; instead RunAs annotation should have been used at method level to associate different identities.
  4,All the same type of bean calls are called using the same identity, here as Person and PayrollBean both are entity beans same identity is used.
Answer: 1
Marks: 4

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

SNo: 148
Ques: You are implementing a banking site for which you have created a SavingAccount entity bean for manipulating the saving bank accounts. You have created a method createAccount in the bean for creating account and closeAccount for closing account. createAccount can be called from SysAdmin and Manager roles. You are programmatically validating the roles of the logged in user using the following code snippet:

if(ctx.isCallerInRole("SysAdmin,Manager"){
  // allow auction to be deleted
}else {
  throw new Exception("The role is invalid");
}

But even though the logged in user has the correct roles 'The role is invalid' exception is thrown. Identify the reason for this unexpected result.
Options:
  1,isCallerInRole should be called only after calling getCallerPrinciple as calling getPrnciple initializes the ejb context.
  2,isCallerInRole accepts only a single role, it cannot be used to validate the roles from a list of comma-separated roles.
  3,isCallerInRole accepts an array of roles in the above code it treats it as a single role and fails.
  4,There is nothing wrong with the code; configuration of the application server must be invalid because of which this issue is happening.
Answer: 2
Marks: 4

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

SNo: 149
Ques: You are implementing a banking site for which you have created the SavingAccount entity bean for manipulating saving bank accounts. You have created three methods in the bean, the createAccount for creating account, the updateAccount for updating the account and the closeAccount for closing account. The createAccount and the updateAccount can be called from Manager role, but the closeAccount can only be called from SysAdmin role. You are using the following code.

@Stateless
@DeclareRoles({"Manager"})
public class BankingBean implements Banking{
    public void createAccount(){...}
    public void updateAccount(){...}
    @RolesAllowed({"SysAdmin"})
    public void closeAccount(){...}
}

While testing the bean you found that there was security vulnerability in the code, even users with Manager role were able to call the closeAccount method. Identify the reason for this unexpected behavior

Options:
  1,When both annotations i.e. DeclareRoles and RolesAllowed are used, the net effect is the aggregation of the roles, so closeAccount method allows both SysAdmin and Manager roles.
  2,RolesAllowed annotation is not a mandatory annotation some containers might not implement it, that's why the enforcing of RolesAllowed is not happening in the above code.
  3,RolesAllowed is introduced in EJB3.0 specifications, so for backward compatibility some containers do not respect this annotation.
  4,When DeclareRoles annotation is used the container neglects the RolesAllowed annotation.
Answer: 1
Marks: 4

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

SNo: 150
Ques: You are implementing a banking site for which you have created the SavingAccount entity bean for manipulating saving bank accounts. You have created three methods in the bean, the createAccount for creating account, the updateAccount for updating the account and the closeAccount for closing account. The createAccount and updateAccount can only be called from SysAdmin role, but closeAccount can also be called from Manager role. You are using the following code:

@Stateless
@RolesAllowed({"SysAdmin"})
public class BankingBean implements Banking{
    public void createAccount(){...}
    public void updateAccount(){...}
   @DeclareRoles({"Manager"})
    public void closeAccount(){...}
}

While compiling the bean you are getting a compilation error. Identify the reason in the preceding code.
Options:
  1,Both annotations i.e. DeclareRoles and RolesAllowed cannot be are used in the same bean.
  2,The bean does not define a default constructor.
  3,DeclareRoles annotation is not allowed at method level.
  4,RolesAllowed annotation is not allowed at class level.
Answer: 3
Marks: 4

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

No comments:

Post a Comment