|
251 A session bean
called SomeBean has a method called someMethod(), which calls someOtherMethod
(same bean) followed by someOtherBeanMethod() of SomeOtherBean. If
SomeMethod() starts a BMT transaction, which of the following are true?
A SomeOtherMethod also has to be
use BMT since it's part of the same bean.
B SomeOtherMethod can use BMT or
CMT, because transactions are defined at the method level in the deployment
descriptor.
C If SomeOtherBean is a Session
Bean, it has to necessarily use BMT since the caller is a BMT method.
D If SomeOtherBean is a Session
Bean, it may use either BMT or CMT.
E If SomeOtherBean is an Entity
Bean, it may use either BMT or CMT.
F If SomeOtherBean is an Entity
Bean, it must necessarily use only CMT.
Choices A, D and F are correct.
A Bean may be defined as either a BMT bean or a CMT bean. One cannot have some
methods of a bean participating in Container Managed Transactions and other
methods participating in Bean Managed Transactions. Hence choice A is correct.
Session Beans may either be defined as CMT beans or BMT beans whereas Entity
beans can only be CMT beans. Hence choices D and F are correct.
The same bean cannot have both BMT and CMT transaction management. Hence
choice B is incorrect.
SomeOtherBean is a different Bean. It may either be defined as a BMT bean or a
CMT bean. Just because the calling bean is in a BMT transaction, all the other
beans do not have to be BMT beans as well. Hence choice C is incorrect.
Entity Beans can only be CMT beans. Hence choice E is incorrect.
252 In EJB 1.1 the
EJB timeout property may be added to the Bean's deployment descriptor for
easier declarative life cycle management. True/False?
A True
B False
The above statement is False.
In EJB 1.0, the timeout period was specified in the deployment descriptor and
defined as number of seconds. Between two business method invocations, the
timer was reset. In EJB 1.1 however, the deployer is allowed to set the
timeout in a vendor dependent manner. Hence the above statement is false.
253 A B2C company
uses J2EE based technologies for its e-commerce storefront. In order to
increase scalability and availability they plan to add capacity to their
existing server and also add a new server. Which of the following statements
are true?
A Adding capacity will improve
scalability, as more memory would allow better bean pooling.
B Adding a server would be
difficult, as EJB servers cannot span multiple physical machines.
C The proposal not does address
horizontal scalability.
D The proposal addresses both
vertical and horizontal scalability.
E Adding a server to the system
would be easy as EJB vendors generally support fault tolerant mechanisms via
server clustering.
Choices A, D and E are correct.
The proposal to add capacity and an additional server address the issue of
scalability. Adding capacity is an example of Vertical Scalability and adding
a new server is an example of Horizontal Scalability. Additional servers also
improve availability because of redundancy and fault tolerance. Hence choices
A, D and E are correct.
Most J2EE vendors provide multi-server support. Hence choice B is incorrect.
Adding a new server is an example of Horizontal scalability. Hence choice C is
incorrect.
254 Company ABC
Inc. has an existing J2EE application that provides an EJB interface. ABC Inc.
is writing a new J2EE based application for enhanced MIS reporting. Which of
the technologies listed below would be ideal for this?
A RMI/JRMP with JNI
B Java IDL
C RMI / IIOP
D JMS
Choice C is correct.
The key here is that ABC Inc. is using a primarily EJB based application. The
protocol used in EJB is RMI-IIOP. Hence choice C is correct.
The question clearly says that the existing application is in EJB. There is no
legacy connectivity involved here. Hence choice A is inappropriate and
therefore incorrect.
Java IDL is primarily used when a majority of the code needs a CORBA
interface. Since the existing code is already in EJB, there is no need for
Java IDL here. Hence choice B is incorrect.
JMS is useful when you want to send messages to other applications
asynchronously via a Message Oriented Middleware. Hence option D is incorrect
as well.
255 A firewall
blocks all requests except those on ports 80 and 443. IIOP requests
A Can be processed because IIOP
always works on port 80
B Cannot be processed because
port 80 belongs to a different protocol
C Can be processed by SSL
D Can be processed via HTTP
blocking
E Can be processed via HTTP
tunneling
Choice E is correct.
Tunneling is a concept that allows requests of one protocol to masquerade as
requests of another protocol, so that they may bypass the firewall. In the
case of HTTP tunneling, requests try to pass of as HTTP requests. Hence choice
E is correct.
Port 80 is the standard port for HTTP requests, not CORBA requests. Hence
choice A is incorrect.
Although port 80 may be used for HTTP, that does not mean that CORBA requests
cannot be processed. As it happens, HTTP tunneling will allow CORBA requests
looking like HTTP requests to pass through port 80. Hence choice B is
incorrect.
SSL stands for Secure Sockets Layer. SSL is a protocol that exists above
TCP/IP and below application level protocols. SSL does not process CORBA
requests. Hence choice C is incorrect.
While firewalls may block requests of certain protocols, there is no concept
called HTTP blocking. Hence choice D is incorrect.
256 Applications
exchange messages through:
A Active channels called
Networks
B Active Channels called Message
Brokers
C Virtual Channels called
Digests
D Virtual Channels called
Destinations
Choice D is correct.
257 Which of the
following are true about Publish/Subscribe?
A Subscribers receive a copy of
every message.
B It is a Pull (Polling) based
model.
C It is a push-based model.
D It is generally used when one
publisher wishes to send a message to one subscriber.
Choices A and C are correct.
In the Publish/Subscribe messaging paradigm the publisher broadcasts a message
to the Message Oriented Middleware (MOM.) The MOM then typically uses a
server-push mechanism to try to push a copy of the message to every subscriber
who showed interest in the topic. Optionally a subscriber may also register as
a durable subscriber, in which case the message will have guaranteed delivery.
Hence choices A and C are correct.
The Point-to-Point (P2P) model is a queue-based model where the message
consumer typically polls the queue for incoming messages. Publish/Subscribe,
on the other hand is a push-based model. Hence choice B is incorrect.
Publish/Subscribe is generally used for a one to many type of communication
while P2P is typically used for a one to one communication. Hence choice D is
incorrect.
258 In the
Publish/Subscribe messaging architecture, publishers send messages to:
A A specified node, which is
then re-distributed to all subscribers. B
Directly to all subscribers in the Topic subscription list.
C A designated queue.
D A component transaction
monitor such as an EJB Server for further processing by a message driven bean.
Choice A is correct.
The Publish subscribe model of messaging is a one to many messaging paradigm
where the publisher typically sends a message to a centralized node. The node
then broadcasts the message to all the topic subscribers, who have registered
their interest in the topic. This allows the publisher and the subscribers to
be decoupled. Further if the subscriber is registered as a durable subscriber,
he will receive the message ultimately even if he is currently inactive. The
MOM provider can thus guarantee delivery and any Quality of Service
requirements pertaining to the message delivery.
Although possible, choice B is not the ideal implementation method, because it
couples publishers and subscribers. Most MOM providers use a server process
that communicates with client processes for establishing heartbeats and for
communicating messages.
Choice C is incorrect because it refers to the Point-to-Point messaging model,
which is typically a one to one communication between two parties.
Choice D is incorrect because the Message Driven Bean is a message listener.
So the best use of a message driven bean would be as a subscriber.
259 1-tier
applications represent a single point of failure, although typically, changes
to one part of the system do not generally affect the whole system.
True/False?
A True
B
False
Choice B is correct.
1-tier systems represent a single point of failure. Further if any changes are
made to one part of the system, typically the whole system may be affected
because of a high degree of tight coupling. Hence choice B is correct.
260 Which of the
following are not true about N-Tier Systems?
A N-Tier systems are distributed
over many systems and hence always present a maintenance problem.
B N-Tier systems are generally
component based and are therefore quite easy to maintain.
C Since N-Tier systems do not
use database stored procedures or triggers for business logic processing, they
are generally very slow.
D Since N-Tier systems are
container based, many N-Tier systems can be easily scaled (both vertically and
horizontally).
E N-Tier systems suffer from
only one drawback over client/server systems - N-Tier systems do not take
advantage of resource sharing techniques such as connection pooling.
F N-Tier systems can use various
techniques for Identification, Authentication and Authorization and are
therefore considered quite secure.
Choices A, C and E are correct.
This is a discussion about the benefits vs. drawbacks of N-Tier applications.
Note that the question says 'not true.'
Though N-Tier systems are distributed over many systems, when architected and
designed well, they do not present any maintenance problems. This is because
they are highly modular (component-container based) and it is relatively easy
to correct problems in one tier without impacting other tiers. Therefore A is
a correct choice.
N-Tier systems can also yield high performance. They can be highly optimized
at each tier. Server clusters can be used where bottlenecks are encountered,
connection pools can be used by applications to acquire and release
connections (a process more effective that creation and destruction of
connections) and so on. Hence choice C is a correct choice.
Though not relevant to the discussion it should be noted that putting all
business rules in the database tier reduces database portability and also
violates tier encapsulation. Hence it is not considered a J2EE best practice
to use stored procedures and triggers extensively for business logic
processing.
As opposed to client/server systems, N-Tier systems generally make extensive
use of resource sharing capabilities. Bean Pools and Connection pools are good
examples. Hence E is a right answer.
B, D and F are good examples of other capabilities of N-Tier systems.
261 In general,
1-tier applications are less horizontally scalable than 3-tier applications,
although from a scalability point of view, client/server applications are the
most scalable. True/False?
A True
B
False
The above statement is False.
This is a trick question. It starts out by making a true statement although
that is not the main stem of the question. The main stem seems to indicate
that Client/Server applications are the most scalable types of applications.
That is incorrect because N-Tier applications are modular and therefore
individual components can be targeted for scaling.
262 Which of the
following do not aid a system's extensibility?
A Modularizing Code
B Using well defined software
design patterns
C Using Servlets to manage
distributed database access
D Using JSP Scriptlets to locate
Enterprise beans
E Using Data Access Objects when
Session Beans or BMP Entity beans have to communicate to the database.
Choices C and D are correct.
Extensibility refers to a systems ability to incorporate new functionality
with ease. Writing Database access code within Servlets or using JSP for
locating Enterprise Java Beans make the code very difficult to maintain. These
are poor programming practices and adversely affect the extensibility of a
system. Hence choices C and D are correct.
Modularized code, good design practices using patterns, and encapsulating
database access with a DAO all make the code easy to maintain, thus rendering
the system easily extensible.
263 Refer to the
following exhibit
In the UML diagram,
A ‘A' has an association
relationship with 'B'
B 'B' has an association
relationship with 'A'
C 'A' extends 'B'
D 'A' has a composition relation
with 'B'
E 'B' has a composition
relationship with 'A'
F 'A' has an aggregation
relationship with 'B'
G 'B' has an aggregation
relationship with 'A'
Choice D is correct.
The relationship between class A and class B represents the strongest form of
association - composition. A solid diamond near the object that will
instantiate the other object in the association, denotes a composition
relationship.
Class A does not have an association or aggregation (open diamond near A)
relationship with class B. Class A also does not extend B (open triangle near
B.) Hence all other choices are incorrect.
264 Refer to the
following exhibit
What UML diagram is shown in the exhibit?
A Class
B
Object
C Component
D Collaboration
E Sequence
F Package
G Node
Choice F is correct.
The diagram denotes a package diagram. A package diagram (Fowler 108) shows
packages of classes and the dependencies among them. Choice F is correct.
265 Which of the
following statements about Interaction diagrams are true?
A Interaction diagrams represent
the dynamic view of a system.
B Interaction diagrams may
represent static or dynamic views of the system.
C Interaction diagrams are
polymorphic.
D Interaction diagrams are
isomorphic.
E Interaction diagrams only show
time ordering of messages.
F Interaction diagrams may show
the structural organization of the objects that send or receive messages.
Choices A, D and F are correct.
Interaction diagrams (Fowler 67) are models that describe how groups of
objects collaborate in some behavior. There are two kinds of Interaction
diagrams - Sequence diagrams and Collaboration diagrams.
(Cade 46) Interaction diagrams address the dynamic view of a system. A
sequence diagram emphasizes on the time ordering of messages whereas a
collaboration diagram emphasizes the structural organization of the objects
that send or receive messages. Sequence diagrams and Collaboration diagrams
are also isomorphic (you can take one and transform it to the other.) Hence
choices A, D and F are correct.
Interaction diagrams do not describe the static view of a system. Hence choice
B is incorrect.
Interaction diagrams are isomorphic, nor polymorphic. Hence choice C is
incorrect.
Interaction diagrams show either the time ordering of messages (sequence
diagrams) or the structural organization of objects (collaboration diagrams.)
Hence choice E is incorrect.
266 Refer to the
following diagram
From the diagram, it can be inferred that:
A A can only have 2 or 4 Bs
associated with it
B A can have 2 to 4 (4 not
inclusive) Bs associated with it
C A can have 2 to 4 (2 not
inclusive) Bs associated with it
D A can have either 2 or 4 Bs
associated with it but not 3
E A can have 3 Bs associated
with it
Choice E is correct.
The multiplicity shown above translates into (A can have 2 to 4 Bs associated
with it.) Choice E says that A can have 3 Bs associated with it and is
therefore correct.
267 Nopester Inc.,
a CD manufacturer uses Metallic Corporation for making jewel cases. When the
inventory of jewel cases falls under the reorder level, Nopester communicates
with Metallic via faxes. Nopester now wants to build a solution for its supply
chain management. Metallic uses a legacy system that supports CORBA interfaces
for other companies to interface to them with. Metallic's servers are
protected by firewalls and will only let HTTP or HTTPS requests
through.
What is Nopester's best option here?
A Since Metallic will not let
CORBA requests through, Nopester should continue sending faxes.
B Nopester should take its
business away to Metallic's competitors.
C Nopester should use the
popular SOAP protocol since SOAP requests communicate over HTTP.
D Nopester should use a concept
called HTTP tunneling to communicate with Metallic.
Choice D is correct.
One of the most common interconnection problems that arise in third party
integrations is that of security. Most companies have strict security policies
and only allow access to the ports that support HTTP and HTTPS. Therefore
CORBA requests generally have to masquerade as HTTP requests to get through
the firewall. While this beats the very purpose of the firewall, such
implementations are quite common. This concept is called HTTP tunneling. Hence
choice D is correct.
Choice A is incorrect for obvious reasons. What is the point of automation if
we still want to use a paper based solution?
Choice B is incorrect because businesses do not change partners due to minor
software issues.
Choice C is incorrect because there is no mention of whether Metallic supports
SOAP in the discussion.
268 Syracuse Sobers
is a National Hockey League team in upstate
New York. They
currently use a mainframe-based application for talent procurement and
management. Their team currently visits various schools and universities
across the country. When they find an interesting candidate, they enter his
profile details in hand held devices. Later the information is faxed to
Syracuse,
where another set of users enters the data into the mainframe.
Given that the Sobers do not want to incur too much
capital and operational expense in rewriting the application, what would be
the quickest way of giving them an Internet based profile management
system?
A Rewrite the system using
Applets.
B Rewrite the system using
Model2 Architecture based solution.
C Use screen scraper for
obtaining an object interface and off-board server for forwarding requests.
D Use RMI with JNI. t+Enable
HTTP tunneling and use CORBA calls.
Choice C is correct.
The key here is 'less expensive' and 'quickest.' Hence the best method under
the given circumstances is the combined use of Screen Scrapers and an
off-board server. Choice C is therefore correct.
Rewriting the system is time consuming and also cost intensive. Hence choices
A and B are incorrect.
There is no mention of the legacy application supporting JNI. The question
mentions that it is a mainframe-based application, making screen scrapers the
safest bet. Hence choice D is incorrect.
There is also no mention of CORBA support. Hence choice E is incorrect.
269 A
Philadelphia
based cable company is using J2EE for their Customer Management system. The
system uses a combination of HTML and JSP for presentation. Java Servlets are
used as Controllers. All Servlets have access to a ServletContext object,
which functions as a Container to the shared resources of the Servlets. The
ServletContext object best exemplifies what design pattern?
A Iterator
B Mediator
C Interpreter
D State
E Singleton
Choice E is correct.
Singleton (GOF 127)" Ensure a class only has one instance, and provide a
global point of access to it." In the example cited above, all Servlets use a
common ServletContext object as a container for the shared resources. This is
a perfect example of the Singleton Design Pattern. Hence choice E is correct.
Iterator (GOF 257)"Provide a way to access the elements of an aggregate object
sequentially without exposing its underlying representation." Hence choice A
is incorrect.
Mediator (GOF 273)"Define an object that encapsulates how a set of objects
interact. Mediator promotes loose coupling by keeping objects from referring
to each other explicitly, and lets you vary their interaction independently."
Hence choice B is incorrect.
Interpreter (GOF 243)"Given a language, define a representation for its
grammar along with an interpreter that uses the representation to interpret
sentences in the language." Hence choice C is incorrect.
State (GOF 305)"Allow an object to alter its behavior when its internal state
changes. The object will appear to change its class." Hence choice D is
incorrect.
270 Since Stateful
Session Beans are not pooled as their Stateless counterparts, the container
uses Passivation and activation techniques for better resource management.
What design pattern is close to the concept of Passivation, as described
here?
A Composite
B Flyweight
C Template Method
D Command
E Memento
F Chain of Responsibility
Choice E is correct.
Memento (GOF 283)"Without violating encapsulation, capture and externalize an
object's internal state so that the object can be restored to this state
later."
With Stateful Session Beans the container externalizes the state of the bean
via Passivation for better memory management. When required, a bean in the
passive state can be brought back to the Method Ready state via activation.
Hence choice E is correct.
Composite (GOF 163)"Compose objects into tree structures to represent
part-whole hierarchies. Composite lets clients treat individual objects and
composites of objects uniformly." Choice A is irrelevant here and therefore
incorrect.
Flyweight (GOF 195)"Use sharing to support large numbers of fine-grained
object efficiently." Hence choice B is therefore incorrect.
Template Method (GOF 325)"Define a skeleton of an algorithm in an operation,
deferring some steps to subclasses. Template Method lets subclasses redefine
certain steps of an algorithm without changing the algorithm's structure."
Choice C is therefore incorrect.
Command (GOF 233)"Encapsulate a request as an object, thereby letting you
parameterize clients with different requests, queue or log requests, and
support undoable operations." Choice D is therefore incorrect.
Chain of Responsibility (GOF 223)" Avoid coupling the sender of a request to
its receiver by giving more than one object a chance to handle the request."
Chain the receiving objects and pass the request along the chain until an
object handles it." Choice F is therefore incorrect.
271 Heaven's
Stairway, an e-auction house allows sellers to put up items for sale.
Potential buyers can subscribe an interest in these items. When somebody
updates the cost with a higher price, the new price information is sent to a
JMS based middleware. The MOM then intimates all subscribers of the event.
What design pattern is illustrated in the discussion here?
A Service to Worker
B Fast Lane Reader
C Observer
D Visitor
E Publish/Subscribe
Choice C is correct.
Observer (GOF 293)"Define a one-to-many dependency between objects so that
when one object changes state, all its dependents are notified and updated
automatically." In the example above, when someone (message producer) updates
the bid price, the MOM has to send a message to all interested subscribers
(message consumers.) This is a good example of the Observer Design Pattern.
Hence choice C is correct.
The following is taken from:
http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceToWorker.html
Service to Worker:"Combine a controller and dispatcher with views and helpers
(see Front Controller and View Helper also) to handle client requests and
prepare a dynamic presentation as the response. Controllers delegate content
retrieval to helpers, which manage the population of the intermediate model
for the view. A dispatcher is responsible for view management and navigation
and can be encapsulated either within a controller or a separate component."
Examples of Service to Worker pattern can be seen in popular Model2 Frameworks
such as Struts and Web Application Framework (WAF.) This pattern is not
relevant to this situation and choice A is therefore incorrect.
The following is taken from:
"The Fast Lane Reader design pattern provides a more efficient way to access
tabular, read-only data. A fast lane reader component directly accesses
persistent data using JDBCTM components, instead of using entity beans. The
result is improved performance and less coding, because the component
represents data in a form that is closer to how the data are used." When EJBs
are not required in an application (smaller applications) and JSP pages need
to access the database to retrieve information, they may use helper classes,
which in turn instantiate DAOs to access data. A JSP page retrieving catalog
information through the CatalogHelper class and the CatalogDAO is a good
example of the Fast Lane Reader Pattern. Hence choice B is incorrect.
Visitor (GOF 331)"Represent an operation to be performed on the elements of an
object structure. Visitor lets you define a new operation without changing the
classes of the elements on which it operates." Choice D is therefore
incorrect.
Publish/Subscribe is a messaging architecture, not a design pattern. Hence
choice E is incorrect.
272 In JMS based
applications components never interact with each other directly. The messages
are always sent to the MOM and the MOM stores and forwards them to the
recipients. This concept helps avoid explicit references and promotes loose
coupling. The MOM is acting as a/an:
A Interpreter
B Visitor
C Mediator
D Service Locator
E Service to Worker
Choice C is correct.
Mediator (GOF 273)"Define an object that encapsulates how a set of objects
interact. Mediator promotes loose coupling by keeping objects from referring
to each other explicitly, and lets you vary their interaction independently."
In this example, the MOM decouples the message producers and consumers from
referring to each other directly, thus acting as a Mediator. Choice C is
therefore correct.
Interpreter (GOF 243)"Given a language, define a representation for its
grammar along with an interpreter that uses the representation to interpret
sentences in the language." Hence choice A is incorrect.
Visitor (GOF 331)"Represent an operation to be performed on the elements of an
object structure. Visitor lets you define a new operation without changing the
classes of the elements on which it operates." Choice B is therefore
incorrect.
The following is taken from:
http://java.sun.com/blueprints/patterns/ServiceLocator.html
"The Service Locator pattern centralizes distributed service object lookups,
provides a centralized point of control, and may act as a cache that
eliminates redundant lookups. It also encapsulates any vendor-specific
features of the lookup process." In Model2 architectures, Controllers may use
Service Locators to delegate business events. Choice D is therefore incorrect.
The following is taken from:
http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceToWorker.html
Service to Worker:"Combine a controller and dispatcher with views and helpers
(see Front Controller and View Helper also) to handle client requests and
prepare a dynamic presentation as the response. Controllers delegate content
retrieval to helpers, which manage the population of the intermediate model
for the view. A dispatcher is responsible for view management and navigation
and can be encapsulated either within a controller or a separate component."
Examples of Service to Worker pattern can be seen in popular Model2 Frameworks
such as Struts and Web Application Framework (WAF.) This pattern is not
relevant to this situation and choice E is therefore incorrect.
273 Compact
Computers is a small computer assembly company. Its online application allows
customers to pick and choose accessories to build their own PCs. The
accessories are:
i. Processor -
800Mhz, 1Ghz, 1.2Ghz
ii.
HDD -
40 GB, 60 GB, 80 GB
iii. Memory - 128 MB, 256 MB, 512 MB
Customers choose parts and quantities during the
order. For example, a customer could choose a second
HDD as a
secondary hard drive or purchase additional
RAM. What
design pattern may be optimal for implementing a suitable design here?
A Factory Method
B Prototype
C Singleton
D Template Method
E Business Delegate
F Builder
Choice B is correct.
Prototype (GOF 117)"Specify the kinds of objects to create using a
prototypical instance, and create new objects by copying this prototype." In
this example, the key is that using prototypical instances (for Hard Drives
and RAM), you can create multiple instances of the required part. Hence choice
B is correct.
Factory Method (GOF 107)" Define an interface for creating an object, but let
subclasses decide which class to instantiate. Factory method lets a class
defer instantiation to subclasses." Factory Method pattern is used when
concrete factory classes are required for creating subclasses. Hence choice A
is incorrect.
Singleton (GOF 127)" Ensure a class only has one instance, and provide a
global point of access to it." Hence choice C is incorrect.
Template Method (GOF 325)"Define a skeleton of an algorithm in an operation,
deferring some steps to subclasses. Template Method lets subclasses redefine
certain steps of an algorithm without changing the algorithm's structure."
Choice D is therefore incorrect.
The following is taken from:
http://java.sun.com/blueprints/patterns/BusinessDelegate.html
"In distributed applications, lookup and exception handling for remote
business components can be complex. When applications use business components
directly, application code must change to reflect changes in business
component APIs.
These problems can be solved by introducing an intermediate class called a
business delegate, which decouples business components from the code that uses
them. The Business Delegate pattern manages the complexity of distributed
component lookup and exception handling, and may adapt the business component
interface to a simpler interface for use by views." Hence choice E is
incorrect.
Builder (GOF 97)"Separate the construction of a complex object from its
representation so that the same construction process can create different
representations." Builder is used to create a complex object made up of
specific types of parts. Here we know the parts but not their quantities.
Hence Builder is inappropriate here and therefore choice F is incorrect.
274 Doomingdale's
has an online application where customers may browse the latest season's
catalogs. At this time no e-commerce is planned. What J2EE technology is best
suited for this application. Note that a study of Internet traffic over the
last two years in a similar company indicated that the site can expect up to
five hundred thousand hits a day although during Thanksgiving, when sales are
at the highest, it could get ten to twenty times higher, perhaps even
more.
A Java Servlets
B JSP with Java classes
C CMP Entity Beans
D BMP Entity Beans
E Stateless Session Beans with
DAO
F Stateful Session Beans with
DAO
Choice E is correct.
The key here is the nature of the application. No e-commerce is planned at
this time, so there may not be any order transactions requiring Entity Beans.
However the site can expect half a million hits each day, the number
increasing exponentially during holiday seasons, indicating that perhaps
Session Beans should be considered for the application. Catalog retrieval can
be done with simple Session beans and DAO. Hence choice E is correct.
Choice A and B are not suitable because using just Java Servlets and JSP alone
may not be the best solution in a system involving heavy usage.
As stated earlier, Entity Beans are not necessary here because there is no
transactional processing. Choices C and D are therefore incorrect.
Stateless Session Beans are sufficient for performing simple database
retrieval operations. Stateful Session Beans are only required when
conversational state needs to be maintained, as in the case of e-commerce
applications with shopping carts. Hence choice F is incorrect.
275 Hiatus Regency
is a popular resort hotel. It has four regional headquarters in the
U.S. There is
also a national headquarters in
Gaithersburg,
MD. All calls
made to the toll-free 800 numbers are routed to the nearest call center. If
the requested city falls outside the region, the call gets rerouted from the
call center appropriately. Hiatus requires a nightly update of all
transactions to the national headquarters for nationwide batch reporting. What
J2EE technology may be best suited for this?
A Java-IDL
B RMI-JRMP
C EJB
D JTA/JTS
E JCA
F JMS
G JAF
Choice F is correct.
Whenever asynchronous communication is required, messaging is the best option.
Most MOM implementations provide guaranteed delivery and high QoS levels.
Further, messaging decouples the producer and consumer and can be used when
bandwidth availability is limited, since no synchronous response is required.
The key here is the nightly update clearly indicating the asynchronous nature
of the communication. Hence choice F is correct.
Java-IDL, RMI-JRMP and EJB are used for synchronous communication. Hence
choices A, B and C are incorrect.
JTA/JTS is used to manage user-defined transactions and is irrelevant to this
discussion. Hence choice D is incorrect.
The following is taken from:
http://java.sun.com/j2ee/connector/
"The J2EE Connector architecture provides a Java solution to the problem of
connectivity between the many application servers and EISs already in
existence. By using the J2EE Connector architecture, EIS vendors no longer
need to customize their product for each application server. Application
server vendors who conform to the J2EE Connector architecture do not need to
add custom code whenever they want to add connectivity to a new EIS." Hence
choice E is incorrect.
The following is taken from:
http://java.sun.com/products/javabeans/glasgow/jaf.html
"With the JavaBeans TM Activation Framework standard extension, developers who
use Java TM technology can take advantage of standard services to determine
the type of an arbitrary piece of data, encapsulate access to it, discover the
operations available on it, and to instantiate the appropriate bean to perform
said operation(s). For example, if a browser obtained a JPEG image, this
framework would enable the browser to identify that stream of data as an JPEG
image, and from that type, the browser could locate and instantiate an object
that could manipulate, or view that image." Hence choice G is incorrect.
276 Which of the
following situations may be best suited for implementation using Servlets and
JSP?
A Need large scale deployment
B Need heavy use of transactions
C Need to process dynamic
requests from HTTP clients
D Need access to relational
databases through a generic set of APIs
E To function as Intercepting
filters, request processors and request dispatcher
F When static templates are
combined with data to form dynamic HTML output
Choices C, E and F are correct.
Servlets and JSP are best suited for applications where there is a need for
processing dynamic requests from HTTP clients. In Model2 architectures,
Servlets are used as Controllers and are responsible for processing incoming
requests, and dispatching them to appropriate handlers. JSP are used as views
to combine static templates with dynamic data to form HTML or XML output.
Hence choices C, E and F are correct.
When an application involves large-scale deployment and heavy transactional
requirements, EJBs are the best technology. Hence choices A and B are
incorrect.
JDBC is used to access relational databases through a generic set of APIs.
Hence choice D is incorrect.
277 What are the
benefits of Bean pooling?
A Bean instances are created
during startup, thus avoiding the expense of creation, each time a client
requests it.
B Bean pooling allows load
distribution over several machines.
C Bean pooling is the
container's way of balancing load - moving future requests from client to a
different machine, if load increases are encountered.
D Allows a container to use
beans as flyweights.
Choices A and D are correct.
One of the advantages of using stateless session beans are that they are light
weight objects and can therefore be used in situations that do not require any
conversational state management. The container makes use of this capability to
create a pool of instances that can be used to service client requests. When a
request is serviced, the bean instance is moved back to the pool. Thus the
expense of creation is avoided each time a client request comes in. Further
the concept of using a smaller number of instances to service a large number
of clients is referred to as the Flyweight pattern (GOF 195), the case with
bean pooling. Therefore choices A and D are correct.
Bean pooling is not responsible for load distribution (something accomplished
by DNS Round Robin.) Some containers working under a clustered environment
achieve load balancing. Again this is not a benefit of bean pooling. Hence
choices B and C are incorrect.
278 What are the
valid life-cycle states an Entity Bean can exist in?
A Does Not Exist, Pooled, Method
Ready
B Does Not Exist Ready, Ready
(in TX), Passivated
C Does Not Exist, Method Ready
Pool
D Does Not Exist, Pooled, Ready
Choice D is correct.
The valid lifecycle states for an Entity Bean are Does Not Exist, Pooled and
Ready. Hence choice D is correct.
Entity Beans do not have a Method Ready state. Hence choice A is incorrect.
When Entity Beans are passivated, they enter the pooled state. Also, there is
no Method Ready (in TX) state for Entity Beans. Hence choice B is incorrect.
The Method Ready Pool state is a lifecycle state for Stateless Session Beans,
not Entity Beans. Hence choice C is incorrect.
279 A company has a
third party billing system that provides C++
API access. In
the current architecture, a daemon process listens on a specified port on the
server for incoming payloads. The incoming payloads are then decoded to the
form command <tab> data. Once the command is known, the process calls
the appropriate
API with the
data. The company is trying to move to a Java based solution. However, until
the billing system is upgraded, they will still need to use the C++ bases
APIs.
What Protocol may be best suited for achieving
this?
A RMI-JRMP with JNI wrappers for
the API calls
B RMI-IIOP (Stateless session
beans making the API calls)
C Custom socket programming to
replace the C++ daemon process with a Java class
D HTTP request making a CGI call
for the Billing updates
E JINI based program to
interface to the APIs
F JCA to make the API call
Choice A is correct.
The key here is that the billing system supports C++ based APIs. The new code
is being written in the Java platform. The best approach here is to write
RMI-JRMP code to talk to the billing system and have JNI wrappers there to
communicate with the C++ APIs. Hence choice A is correct.
The question says that the billing system only supports C++ APIs. Hence choice
B is incorrect.
While custom Java socket programming may be used on the server side to replace
the C++ process, in order to call the APIs, C++ wrappers will still be
required. Hence choice C is incorrect.
HTTP, JINI and JCA do not satisfy the requirement of the C++ wrapper need.
Hence choices D, E and F are also incorrect.
280 Which of the
following statements are true?
A The java.text package contains
classes and interfaces for handling text in a locale-sensitive way.
B The java.text package contains
the Locale class and classes for Date and Time.
C The java.util package contains
classes for importing and exporting non-Unicode character data.
D The java.util package contains
the Locale class and classes for Date and Time
Choices A and D are correct.
The java.text and java.util packages are used to support Java
Internationalization. The java.text package has classes and interfaces for
handling locale specific text and the java.util package containes the Locale
class and other classes for Date and Time manipulation. Hence choices A and D
are correct.
The java.util package contains the Locale class and Date and Time classes.
Hence choice B is correct.
The InputStreamReader and OutputStreamWriter classes handle non-Unicode
character data conversion. These classes are found in the java.io package.
Hence choice C is incorrect.
281 The
representation of a set of cultural and language preferences is done using
which class?
A java.util.LanguagePreference
B java.text.MessageFormat
C ResourceBundle
D
Locale
Choice D is correct.
The following is taken from:
http://java.sun.com/products/jdk/1.1/docs/guide/intl/intl.doc.html#26726
"A Locale object represents a specific geographical, political, or cultural
region. An operation that requires a locale to perform its task is called
locale-sensitive and uses the Locale object to tailor information for the
user. For example, displaying a number is a locale-sensitive operation- the
number should be formatted according to the customs and conventions of the
user's native country, region, or culture." Hence choice D is correct.
There is no LanguagePreference class. Regional preferences are addressed
through various I18N features such as ResourceBundle, Locale and so on. Hence
choice A is incorrect.
The following is taken from:
http://java.sun.com/products/jdk/1.1/docs/guide/intl/intl.doc.html#24167
"The class MessageFormat provides a means to produce concatenated messages in
language-neutral way. The MessageFormat object takes a set of objects, formats
them, and then inserts the formatted strings into the pattern at the
appropriate places." Hence choice B is incorrect.
The following is taken from:
http://java.sun.com/products/jdk/1.1/docs/guide/intl/intl.doc.html#23039
"The class ResourceBundle is an abstract base class representing containers of
resources. Programmers create subclasses of ResourceBundle that contain
resources for a particular locale. New resources can be added to an instance
of ResourceBundle, or new instances of ResourceBundle can be added to a system
without affecting the code that uses them. Packaging resources as classes
allows developers to take advantage of Java's class loading mechanism to find
resources.
Resource bundles contain locale-specific objects. When a program needs a
locale-specific resource, a String object for example, the program can load it
from the resource bundle that is appropriate for the current user's locale. In
this way, the programmer can write code that is largely independent of the
user's locale isolating most, if not all, of the locale-specific information
in resource bundles." Hence choice C is incorrect.
282 What is the
difference in the Java Security model between JDK 1.1 and JDK1.2 with regards
to applets?
A There is no difference between
the two JDK versions in question. Applets are always confined to the sandbox.
B In JDK 1.1, applets are never
trusted and in JDK 1.2 they always are.
C JDK 1.2 fixed a flaw in the
JDK 1.1 security policy. There are no security holes in JDK 1.2 because
Applets are never trusted.
D In JDK 1.1 only signed applets
were trusted whereas in JDK 1.2, any applet with the right security
permissions can be trusted.
Choice D is correct.
The following is taken from:
http://java.sun.com/docs/books/tutorial/security1.2/overview/index.html
"JDK 1.1 introduced the concept of a "signed applet," as illustrated in the
next figure. A digitally signed applet is treated like local code, with full
access to resources, if the public key used to verify the signature is
trusted. Unsigned applets are still run in the sandbox. Signed applets are
delivered, with their respective signatures, in signed JAR (Java Archive)
files.
JDK 1.2 introduces a number of improvements over JDK 1.1. First, all code,
regardless of whether it is local or remote, can now be subject to a security
policy. The security policy defines the set of permissions available for code
from various signers or locations and can be configured by a user or a system
administrator. Each permission specifies a permitted access to a particular
resource, such as read and write access to a specified file or directory or
connect access to a given host and port.
The runtime system organizes code into individual domains, each of which
encloses a set of classes whose instances are granted the same set of
permissions. A domain can be configured to be equivalent to the sandbox, so
applets can still be run in a restricted environment if the user or the
administrator so chooses. Applications run unrestricted, as before, by default
but can optionally be subject to a security policy." As we can see, the Java 2
Security model is totally flexible. Hence choice D is correct.
Choices A, B and C are incorrect because there are differences between the JDK
1.1 and JDK 1.2 security model and signed applets were trusted in JDK 1.1
whereas all applets are subject to a security policy in JDK 1.2.
283 Which of the
following are mandatory steps in the SSL handshake?
A Validate Client to Server
B Validate Server to Client
C Allow client and server to
choose cryptographic algorithm
D Use symmetric key encryption
to generate shared secrets
Choices B and C are correct.
When a client tries to establish an SSL connection with a server, the server
identifies itself to the client. The client may optionally identify itself to
the server. The client and the server then choose the best cryptographic
algorithm. Public Key Cryptography is used to generate shared secrets and
Symmetric Key Cryptography is then used for communication. Hence choices B and
C are correct.
The client's validation to the server is an optional step in the SSL
handshake. Hence choice A is incorrect.
Public Key Cryptography is used to generate shared secrets. Hence choice D is
incorrect.
284
When a Stateful Session Bean is
passivated, what activities should the developer perform in the ejbPassivate()
method?
A Close all open resources
B Set transient fields to NULL
C Set Non-transient fields to
NULL
D Set non-transient
non-serializable fields to NULL
Choices A and D are correct.
During Passivation, it is the developer's responsibility to ensure that all
open resources are closed and all non-transient non-serializable fields are
set to NULL. Therefore choices A and D are correct.
There is no need to set transient fields to NULL. They will not be serialized
anyway. Therefore choice B is incorrect.
If Non-transient fields are set to NULL, there is no point in serializing the
bean instance. Hence choice C is incorrect.
285 Session Bean
SB1 calls a method in another Session Bean SB2. If the calling
Bean has a
transactional scope, with which of the following attributes in SB2, will the
transaction not be propagated?
A Supports
B Required
C Not Supported
D Requires New
E Mandatory
F Never
Choices C, D and F are correct.
The following is taken from:
http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/transactions/transactions7.html
"Transaction Attributes: A transaction attribute is a value associated with a
method of an enterprise bean that uses container-managed transaction
demarcation. A transaction attribute is defined for an enterprise bean method
in the bean's deployment descriptor, usually by an application component
provider or application assembler. The transaction attribute controls how the
EJB container demarcates transactions of enterprise bean methods. In most
cases, all methods of an enterprise bean will have the same transaction
attribute. For optimization purposes, it is possible to have different
attributes for different methods. For example, an enterprise bean may have
methods that do not need to be transactional.
A transaction attribute must be specified for the methods in the component
interface of a session bean and for the methods in the component and home
interfaces of an entity bean.
Required - If the transaction attribute is Required, the container ensures
that the enterprise bean's method will always be invoked with a JTA
transaction. If the calling client is associated with a JTA transaction, the
enterprise bean method will be invoked in the same transaction context.
However, if a client is not associated with a transaction, the container will
automatically begin a new transaction and try to commit the transaction when
the method completes.
RequiresNew - If the transaction attribute is RequiresNew, the container
always creates a new transaction before invoking the enterprise bean method
and commits the transaction when the method returns. If the calling client is
associated with a transaction context, the container suspends the association
of the transaction context with the current thread before starting the new
transaction. When the method and the transaction complete, the container
resumes the suspended transaction.
NotSupported - If the transaction attribute is NotSupported, the transactional
context of the calling client is not propagated to the enterprise bean. If a
client calls with a transaction context, the container suspends the client's
transaction association before invoking the enterprise bean's method. After
the method completes, the container resumes the suspended transaction
association.
Supports - It the transaction attribute is Supports and the client is
associated with a transaction context, the context is propagated to the
enterprise bean method, similar to the way the container treats the Required
case. If the client call is not associated with any transaction context, the
container behaves similarly to the NotSupported case. The transaction context
is not propagated to the enterprise bean method.
Mandatory - The transaction attribute Mandatory requires the container to
invoke a bean's method in a client's transaction context. If the client is not
associated with a transaction context when calling this method, the container
throws javax.transaction.TransactionRequiredException if the client is a
remote client or javax.ejb.TransactionRequiredLocalException if the client is
a local client. If the calling client has a transaction context, the case is
treated as Required by the container.
Never - The transaction attribute Never requires that the enterprise bean
method explicitly not be called within a transaction context. If the client
calls with a transaction context, the container throws
java.rmi.RemoteException if the client is a remote client or
javax.ejb.EJBException if the client is a local client. If the client is not
associated with any transaction context, the container invokes the method
without initiating a transaction."
With Not Supported, Requires New and Never, the existing transaction's scope
will not be propagated. Therefore choices C, D and F are correct and choices
A, B and E are incorrect.
286 The findByXxx()
method in the Home Interface of an entity bean returns
A An Instance of
java.lang.Object
B An instance of the Remote
Reference to the bean
C An instance of
java.util.Enumeration
D An instance of the Bean class.
Choices B and C are correct.
The finder methods return either an instance of the Remote Reference to the
bean or an instance of java.lang.Enumeration (if multiple rows are found.)
Therefore choices B and C are correct.
The finder methods never return an instance of java.lang.Object. Choice A is
therefore incorrect.
The bean class is never explicitly returned to the client. The client always
only works with the remote reference to the bean class. Choice D is therefore
incorrect.
287 With Bean
Managed Persistence, what are the developer's responsibilities in terms of
data synchronization?
A The DML statements for
inserting, deleting and updating data are coded in appropriate methods and the
client program is responsible for synchronizing data by calling the methods
appropriately.
B The DML statements for
inserting, deleting and updating data are coded in appropriate methods but
since ejbLoad() and ejbStore() are callback methods, the container makes calls
to them, as needed.
Choice B is correct.
With BMP, although the code necessary for inserting, deleting and updating
data is provided by the developer, the container still decides when to
synchronize the Bean's state with the database. The container makes this
decision based on various activities including the current transactional
context and so on. The client does not call the callback methods explicitly.
Hence choice B is correct.
Choice A is incorrect because it suggests that it is the client's
responsibility to invoke the callback methods.
288 Under which of
the following conditions should you use an Entity Bean?
i. The bean
represents a business entity, not a procedure.
ii. The bean's
state must be persistent. If the bean instance terminates or if
the J2EE server is shut down, the bean's state still
exists in persistent storage (a database).
A Choice (i) only
B Choice (ii) only
C Choice (i) or (ii) depending
on whether the Container is EJB 1.0 compliant or EJB 1.1 compliant
D Both choice (i) and (ii)
Choice D is correct.
Entity Beans are best used when the bean represents a business entity and when
the bean's state must be persistent. Hence choice D is correct.
i. The bean represents a business entity, not a procedure.
ii. The bean's state must be persistent. If the bean instance terminates or if
the J2EE server is shut down, the bean's state still exists in persistent
storage (a database).
|