Wednesday 26 July 2017

NIIT HTML MT ~ GNIIT HELP

HTML MT Solved

1. Explain the usage of the <IFRAME> tag in HTML. Also, discuss the various attributes of the <IFRAME> tag.
Ans .The HTML <IFRAME> tag is used to specify an inline frame. It allows you to divide a Web page into sections or frames. Each section can be used to display an individual Web page. Therefore, the <IFRAME> tag is used to embed an HTML Web page within another Web page. The embedded Web page is said to be contained within the other Web page, which is known as the containing page. The following attributes can be used with the <IFRAME> tag:

src: Is used to specify the location or the URL of the Web page to be embedded inside the frame.

name: Is used to assign a name to the frame.

seamless: Is a boolean attribute, which instructs the browser to display the frame as a part of the containing Web page. If this attribute is used, the frame is displayed without scroll bars and border.

srcdoc: Is used to specify an HTML code that defines the content to be displayed inside the frame.

height: Is used to set the height of the frame.

width: Is used to set the width of the frame.


2.What do you mean by loop constructs? Discuss the various loop constructs in JavaScript.
Ans. Loop constructs are used to repeatedly execute one or more lines of code. In JavaScript, the following loop constructs can be used:

while
do...while
for
The while  loop is used to repeatedly execute a block of statements till a condition evaluates to true. The while statement always checks the condition before executing the statements in the loop. The syntax for the while loop is:

while (expression)
{
statements;
}

The do...while loop construct is similar to the while loop construct. However, the statements within the do...while loop are executed before the condition is checked as compared to the while loop, where the statements within the block are executed after the condition is checked. Therefore, the statements within the do...while loop are executed at least once, in comparison to the while loop, where the statements in the block are not executed when the condition evaluates to false for the very first time. It has the following syntax:

do
{ Statements;
}
while(condition)

The for  loop allows the execution of a block of code depending on the result of the evaluation of the test condition. It has the following syntax:

for (initialize variable; test condition; step value)
{// code block
}

3.
Write the code to retrieve the users' location on the click event of a button by using the getCurrentPosition() method. The location coordinates that are retrieved need to be displayed inside the <P></P> tag.
Ans. <!DOCTYPE HTML>
<HTML>
<BODY>
<P ID="disp_location">Click here to know your location coordinates:</P>
<BUTTON onclick="getLocation()">Get Location</Button>
<SCRIPT>
var geo=document.getElementById("disp_location");
function getLocation()
  {
  if (navigator.geolocation)
    {
    navigator.geolocation.getCurrentPosition(getPosition);
    }
  else{geo.innerHTML="Geolocation is not supported by this browser.";}
  }
function getPosition(position)
  {
  geo.innerHTML="Latitude: " + position.coords.latitude +
  "<BR>Longitude: " + position.coords.longitude;
  }
</SCRIPT>
</BODY>
</HTML>

4. What is a function? How can you create a function in JavaScript?
Ans. A function is a self-contained block of statements that has a name and is defined to perform a specific task. A function can be defined once but can be executed repeatedly. Functions can either be built-in or user-defined.

In JavaScript, functions can be created by using the keyword, function, followed by the function name and the parentheses, ().A function can optionally accept a list of parameters. The parameters that a function accepts are provided in parentheses and separated by commas. The function can use the values passed in these parameters to perform certain operations. The following syntax is used to create functions:

function [functionName] (Variable1, Variable2)
{
//function statements
}

5. Write the JavaScript code to create a clock that updates every one second to display the current time inside a <DIV> element on the Web page.
Ans. <!DOCTYPE HTML>
<HTML>
<HEAD>
<SCxRIPT type="text/javascript">
function clockTime()
{
var todayDate=new Date();
var hrs=todayDate.getHours();
var mns=todayDate.getMinutes();
var scs=todayDate.getSeconds();
mns=check(mns);
scs=check(scs);
document.getElementById('displayTime').innerHTML=hrs+":"+mns+":"+scs;
t=setTimeout('clockTime()',1000);
}

function check(t)
{
if (t<10)
 {
 t="0" + t;
 }
return t;
}
</SCRIPT>
</HEAD>
<BODY onload="clockTime()">
<DIV ID="displayTime"></DIV>
</BODY>
</HTML>

6. Define canvas. Also, discuss how can you create a canvas and use it for drawing graphic objects in HTML.
Ans. A canvas is an area on a Web page that acts as a container for embedding graphic objects. It allows dynamic rendering of bitmap images and 2D shapes by using JavaScript. To create a canvas and use it for drawing, you need to perform the following tasks:

1. Define the canvas
2. Access the canvas

A canvas is defined by using the <CANVAS> tag in the body section of the HTML document. Its important attributes are height, width, style, and ID. You can define a canvas by using the following code within the <BODY> tag:

<CANVAS ID="myCanvas" width="300" height="300" style="border:1px solid black">
</CANVAS>

To actually draw graphic objects on the canvas, you need to access the canvas in the JavaScript code. You can write the following code in the <BODY> tag to access the canvas that you have defined earlier:

<SCRIPT>
var c=document.getElementByID("myCanvas");
var ctx=c.getContext("2d");
</SCRIPT>

7. Write a code to create a table in HTML, as shown in the following figure.
Ans. <!DOCTYPE HTML><HTML>
<BODY>
<TABLE border = "1">
<THEAD>
<TR><TH colspan= "4">Sales Record</TH></TR>
<TR> <TH> Product ID </TH> <TH> Description</TH> <TH> Quantity</TH><TH> Price</TH></TR>
</THEAD>
<TFOOT>
<TR><TD colspan= "3"> Total price </TD> <TD>$12</TD></TR>
</TFOOT>
<TBODY>
<TR><TD>101</TD><TD>Notebook</TD><TD>50</TD><TD>$5</TD></TR>
<TR><TD>121</TD><TD>Pen</TD><TD>100</TD><TD>$7</TD></TR>
</TBODY>
</TABLE>
</BODY>
</HTML>

8. What do you understand by preloading the images associated with a Web page? How is preloading of images implemented in JavaScript?
Ans. Preloading images is a technique to load images in the browser cache before the script on the Web page is executed and the Web page is rendered in the browser window. This helps to avoid any delay in loading images from their respective locations, and then displaying these images on the Web page.

The Image object can be used to preload images in an application. To use the Image object, an instance of the Image object needs to be created and the actual images need to be attached to the Image object in the head section. It ensures that the images are loaded in memory before the body of the page gets loaded. The following syntax is used to create an instance of the Image object:

var Imagename= new Image([Width], [Height]);

After instantiating an image object, you need to associate the image with the Image object. For this, the src attribute of the Image object is used as shown in the following code:

   Imagename.src="ImageURL",

where, ImageURL is the URL of the image.

9. What is the use of the <FIELDSET> tag in HTML? Also, briefly discuss the tags and attributes associated with the <FIELDSET> tag.
Ans. The <FIELDSET> tag is used to combine and group related fields in a form. It creates a box around the selected fields.

The <LEGEND> tag is used along with the <FIELDSET> tag to define a caption for the fieldset. It is the simplest way of organizing form elements along with their description in such a way that it is easier for a user to understand.

The <FIELDSET> tag can have the following attributes:

disabled: The disabled attribute is used to indicate that a group of fields should be shown disabled when the page loads.
form: The form attribute is used to specify the name of one or more forms to which the <FIELDSET> tag belongs.
name: The name attribute is used to specify the name for the fieldset.

10. Write the code to create a canvas of desired dimension on a Web page and then draw a circle inside it. In addition, you need to apply a radial gradient comprising any four colors on the circle drawn on the canvas.
Ans. <!DOCTYPE HTML>
<HTML>   <BODY>
<CANVAS ID="myCanvas" width="300" height="300" style="border:1px solid black">
</CANVAS>
<SCRIPT>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var grad=ctx.createRadialGradient(75,50,5,90,60,100);
grad.addColorStop(0.2,"orange");
grad.addColorStop(0.4,"green");
grad.addColorStop(0.6,"yellow");
grad.addColorStop(0.8,"red");
ctx.fillStyle=grad;
ctx.beginPath();
ctx.arc(80, 90, 50, 0, Math.PI*2, false);
ctx.fill();
ctx.closePath();
</SCRIPT>
</BODY>
</HTML>
Read More »

NIIT ASP.NET MT ~ GNIIT HELP

ASP MT Solved
Ques1 Conside a scenario where you are trying to directky deploy a web application on the IIS server of your development computer.As the first step Internet Information Services(IIS) Manager and currently accessing the Add Apllication dialog box.At this stage which of the following information (ch11)

1.A name of the application,A URL to access the application
2.The pysical path where the website will be saves,A URL to access the application
3.An Alias name of the application,The physical path where the application will be saved
4.The URL to access IIS,The physical path where the website will be saved.


================================
Ques2 When you execute the application,the application is automatically deployed on____.
(ch11)
=====================
Ques3 DatePicker Code(ch8)
====================
Ques4 Create CSS file code(ch6)
===============
Ques5 The IEnumarable interface is avaible in the ____ namespaces.(ch6)
===============
Ques6 Range Data Annotation(ch4)
=====================
Ques7 To implement client-side validation in an MVC application,which one of the follwing options is not required?
1.Add annotation to the model class
2.use HTML validation helpers in Razor view to display error message
3.Include the jQuery validation script
4.Add custom error message to annotation in model class
=========================
Ques8 Which of the follwing statements is true regarding the ReadOnly attribute applied to a property? (ch 4)
1.Ensures that the property is not made availble to the view
2.Specifies constraints for a numeric value entered by the user
3.Ensures that the default model binder will not set the property with a new value from the request
4.Helps you provide information about the specific purpose of a property at runtime
=========================
Ques9 In server-side validation,if the model state contains an error,the ____property retuns false
1.ModelState.IsValid
2.ModelState.Valid
3.ModelState.IsError
4.ModelState.IsInValid
=========================
Ques10 Which one of the following code snippet will generate a URL of the Login action in the Account controller?
1.@HTMl.ActionLink("Login","Action")
2.@Url.ActionLink("Login","Action")
3.MvcHtmlString.ActionLink("Login","Action")
4.@Url.Action("Login","Account")
=====================
Ques11 RadioButton coding(from book Topic Helper Method)
====================
Ques12 The _____ helper method is used to display an editor for the specified model property.
================
Ques13 Custom Route(Go through the Animation)

Identify the URL that cannot match with the following
===================
Ques14 What wll be the result when the following URL is sent to an MVC application through a Web browser?
http://newbay.com/Index/RegistrationController
=====================
Ques15 Chris is given an existing ASP.NET MVC application created by using scaffolding feature.In the application,he has to make changes to the HTMl template.Which options?
1.Views folder
2.Web config file
3.App_Data folder
4.Controller folder
=======================
Ques16 You have created a controller for a web apllication with the name Tutorial.What will be the name of the folder created by default under the Views folder if you use the scallofding
1.Tutorial
2.TutorialController
3.Home
4.Controller
=============================
Ques17 FadeIn() and FadeOut() methods of JavaScript coding
=========================
Read More »

NIIT DSA MT ~ GNIIT HELP

DSA MT Solved

Q Explain queue with the help of an example. What are the types of operations that can be performed on a queue? How can you represent a queue in the form of a linked list?
---------------------------
Ans
A queue is a list of elements in which items are inserted at one end of the queue and deleted from the other end of the queue. You can think of a queue as an open ended pipe, with elements being pushed from one end and coming out of another. The end at which elements are inserted is called the rear, and the end from which the elements are deleted is called the front. A queue is also called a First-In-First-Out (FIFO) list because the first element to be inserted in the queue is the first one to be deleted. The queue data structure is similar to the queues in real life.
The following two types of operations can be performed on queues:
•Insert: It refers to the addition of an item in the queue. Items are always inserted at the rear end of the queue.
•Delete: It refers to the deletion of an item from a queue. Items are always deleted from the front of the queue. When an item is deleted, the next item in the sequence becomes the front end of the queue.


class Node
{
public int data; public Node next;
}
class LinkedQueue
{
Node FRONT, REAR;
public LinkedQueue()
{
FRONT = null;
REAR = null;
}
public void insert (int element)
{
}
public void remove()
{
}
public void display()
{
}
}
===========================================
Q Peter has been assigned a task to develop a code to implement a delete operation on a binary search tree. However, before doing so, he first needs to write a code to locate the position of the node to be deleted and its parent. To do so, he has written the following algorithm:

1. Make a variable/pointer currentNode point to the root node.
2. Make a variable/pointer parent point to root.
3. Repeat the steps, a, b, and c until currentNode becomes NULL or the value of the
    node to be searched becomes greater than currentNode:
    a. Make parent point to currentNode.
    b. If the value to be deleted is greater than that of currentNode:
         i. Make currentNode point to its left child.
    c. If the value to be deleted is less than that of currentNode:
         i. Make currentNode point to its right child.

However, the preceding algorithm does not give the desired output. Write the correct algorithm.
-------------------
Ans
1. Make a variable/pointer currentNode point to the root node.
2. Make a variable/pointer parent point to NULL.
3. Repeat the steps, a, b, and c until currentNode becomes NULL or the value of the
    node to be searched becomes equal to that of currentNode:
    a. Make parent point to currentNode.
    b. If the value to be deleted is less than that of currentNode:
         i. Make currentNode point to its left child.
    c. If the value to be deleted is greater than that of currentNode:        
         i. Make currentNode point to its right child.
===============================
 Q.How can you represent a stack by using a linked list?
Ans...

 Code in C#
class Node {
       public int info;
        public Node next;
public Node(int i, Node n)
{        
  info = i;
  next = n;
}}

After representing a node of a stack, you need to declare a class to implement operations on a stack. In this class, you also need to declare a variable/pointer to hold the address of the topmost element in the stack and initialize this variable/pointer to contain the value, NULL.
class Stack
   {  
    Node top;  
    public Stack()
      {  
       top = null;
       }
       bool empty()
   {            // Statements        }
      public void push(int element)
        {            // Statements        }
     public void pop()    
  {             // Statements        }}

After declaring the class to implement the operations on the stack, you need to implement the PUSH and POP operations.

==============================================================
Q. Define the following terms:
a.    Edge
b.    Depth  of a tree
c.    Leaf node
d.    Degree of a node
e.    Children of a node

Ans..
    Edge:  A link from a parent to a child node is known as an edge.
b.    Depth of a tree:  The maximum number of levels in a tree is called the depth of
       a tree.
c.    Leaf node: A node with no children is called a leaf node.
d.    Degree of a node: The number of sub trees of a node is called the degree of a
       node.
e.    Children of a node: The roots of the sub trees of a node are called the children of
       the node.


=========================================================================
Q.  Explain stack with the help of an example. What are the characteristics of a stack? Briefly explain the operations that can be performed on a stack?

Ans.
A stack is a collection of data items that can be accessed at only one end, which is called top. This means that the items are inserted and deleted at the top. The last item that is inserted in a stack is the first one to be deleted. Therefore, a stack is called a Last-In-First-Out (LIFO) data structure.
A stack is like an empty box containing books, which is just wide enough to hold the books in one pile. The books can be placed, as well as removed, only from the top of the box. The book most recently put in the box is the first one to be taken out. The book at the bottom is the first one to be put inside the box and the last one to be taken out.
The characteristics of stacks are:
1.  Data can only be inserted on the top of the stack.
2.  Data can only be deleted from the top of the stack.
3.  Data cannot be deleted from the middle of the stack. All the items from the top
     first need to be removed.
The following two basic operations can be performed on a stack:
1.  PUSH
2.  POP
When you insert an item into a stack, you say that you have pushed the item into the stack. When you delete an item from a stack, you say that you have popped the item from the stack.



==========================================================================
Q. John has been assigned a task to develop a code to implement preorder traversal of a binary tree. He has developed the code according to the following algorithm:
preorder (root)
1. If (root = NULL):  
     a. Exit.
2. preorder (left child of root).
3. Visit (root).
4. preorder (right child of root).

Analyze the algorithm and check if the same will execute as expected. Suggest changes, if required. Also, write the algorithm for postorder traversal of a binary tree.
==
Ans.
The given algorithm is incorrect. The algorithm for preorder traversal of tree is:
preorder (root)
1. If (root = NULL):  
     a. Exit.
2. Visit (root).
3. preorder (left child of root).
4. preorder (right child of root).

The algorithm for postorder traversal of a tree is:
postorder (root)
1. If (root = NULL):  
     a. Exit.
2. postorder (left child of root).
3. postorder (right child of root).
4. Visit (root).
===========================================================================
Q.  Explain stack with the help of an example. What are the characteristics of a stack? Briefly explain the operations that can be performed on a stack?
==
Ans.
A stack is a collection of data items that can be accessed at only one end, which is called top. This means that the items are inserted and deleted at the top. The last item that is inserted in a stack is the first one to be deleted. Therefore, a stack is called a Last-In-First-Out (LIFO) data structure.
A stack is like an empty box containing books, which is just wide enough to hold the books in one pile. The books can be placed, as well as removed, only from the top of the box. The book most recently put in the box is the first one to be taken out. The book at the bottom is the first one to be put inside the box and the last one to be taken out.
The characteristics of stacks are:
1.  Data can only be inserted on the top of the stack.
2.  Data can only be deleted from the top of the stack.
3.  Data cannot be deleted from the middle of the stack. All the items from the top
     first need to be removed.
The following two basic operations can be performed on a stack:
1.  PUSH
2.  POP
When you insert an item into a stack, you say that you have pushed the item into the stack. When you delete an item from a stack, you say that you have popped the item from the stack.
==================================================================
Q.  Explain briefly how can you represent a binary tree?
==
Ans..
To represent a binary tree, you need to declare two classes:
•A class to represent a node of the tree: This class represents the structure of each node in a binary tree. A node in a binary tree consists of the following parts:
?Information: It refers to the information held by each node in a binary tree.
?Left child: It holds the reference of the left child of the node.
?Right child: It holds the reference of the right child of the node.


•A Class to represent the binary tree: This class implements various operations on a binary tree, such as insert, delete, and traverse. The class also provides the declaration of the variable/pointer root, which contains the address of the root node of the tree.

==============================================================================
Read More »

NIIT CORE JAVA MT ~ GNIIT HELP

Core Java Subjective Question
1.Identify the features of New API (NIO).
Ans:
i)The new API works more consistently across platforms.
ii)It makes it easier to write programs that gracefully handle the failure of file system operations.
iii)It provides more efficient access to a larger set of file attributes.

2.Differentiate between checked and unchecked exceptions.
Ans:
Checked Exception:
i)Every class that is a subclass of Exception except RuntimeException and its subclasses falls into the category of checked exceptions.
ii)You must ?handle or declare? these exceptions with a try or throws statement.

Unchecked Exception:
i)java.lang.RuntimeException and java.lang.Error and their subclasses are categorized as unchecked exceptions.
ii)You may use a try-catch statement to help discover the source of these exceptions, but when an application is ready for production use, there should be little code remaining that deals with RuntimeException and its subclasses.

3.Explain public, static, and void keywords in the following statement:
public static void main(String args[])
Ans:
i)public: The public keyword indicates that the method can be accessed from anyobject in a Java program.
ii)static: The static keyword is used with the main() method that associates the method with its class. You need not create an object of the class to call the main() method.
iii)void: The void keyword signifies that the main() method returns no value.

4.Identify the limitations of the java.io.File class.
Ans:
The java.io.File class has the following limitations:
i)Many methods did not throw exceptions when they failed, so it was impossible to obtain useful error messages.
ii)Several operations were missing (file copy, move, and so on).
iii)The rename method did not work consistently across platforms.
iv)There was no real support for symbolic links.
v)More support for metadata was desired, such as file permissions, file owner, and other security attributes.
vi)Accessing file metadata was inefficient?every call for metadata resulted in a system call, which made the operations very inefficient.
vii)Many of the File methods did not scale. Requesting a large directory listing on a server could result in a hang.
viii)It was not possible to write reliable code that could recursively walk a file tree and respond appropriately if there were circular symbolic links.

5.Identify the five classes of the java.util.concurrent package and explain any two classes.
Ans:
i)Semaphore: Is a classic concurrency tool.
ii)CountDownLatch: A very simple yet very common utility for blocking until a given number of signals, events, or conditions hold.
iii)CyclicBarrier: A resettable multiway synchronization point useful in some styles of parallel programming.
iv)Phaser: Provides a more flexible form of barrier that may be used to control phased computation among multiple threads.
v)Exchanger: Allows two threads to exchange objects at a rendezvous point, and is useful in several pipeline designs.

6.Steve has been asked to automate the Library Management System either in C++ or Java. Steve has chosen to develop the project in Java. Identify the reason.
Ans:
One of the major problem areas in most of the object-oriented languages, such as C++, is to handle memory allocation. Programmers need to explicitly handle memory in the program for its optimum utilization. To handle memory allocation, they use pointers that enable a program to refer to memory location of the computer. However, Java does not support pointers and consists of the built-in functionality to manage memory.

7.You have created a class with two instance variables.You need to initialize the variables automatically when a class is initialized. Identify the method that you will use you to achieve this. In addition, describe the characteristics of this method.
Ans:
You can initialize the variable by using the constructor. The characteristics of a constructor are:
-       A constructor has the same name as the class itself.
-       There is no return type for a constructor. A constructor returns the instance of the class instead of a value.
-        A constructor is used to assign values to the data members of each objectcreated from a class

8.Differentiate between interface and abstract class.
Ans:
1.The methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behavior.
2.Variables declared in a Java interface are by default final. An abstract class may contain non-final variables.
3.Members of a Java interface are public by default. A Java abstract class can have the usual flavors of class members like private, protected, etc..
4.Java interface should be implemented using keyword, implements; A Java abstract class should be extended using keyword, extends.
5.An interface can extend another Java interface only, an abstract class can extend another Java class and implement multiple Java interfaces.
6.A Java class can implement multiple interfaces but it can extend only one abstract class.
7.Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.
8.In comparison with Java abstract classes, Java interfaces are slow as it requires extra indirection.
Read More »

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

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

Read More »