|
226 You can
traverse through the elements of many Java Collection objects because they
provide a way to access their elements sequentially. What design pattern is
used here?
A Visitor
B Observer
C Builder
D Iterator
E Proxy
F Decorator
Choice D is correct.
Iterator (GOF 257)"Provide a way to access the elements of an aggregate object
sequentially without exposing its underlying representation." Hence choice D
is correct.
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." Hence choice A is incorrect.
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." Hence choice B 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." Hence choice C is incorrect.
Proxy (GOF 207)"Provide a surrogate or placeholder for another object to
control access to it." Hence choice E is incorrect.
Decorator (GOF 175)"Attach additional responsibilities to an object
dynamically. Decorators provide a flexible alternative to subclassing for
extending functionality." Hence choice F is incorrect.
227 Compact
Computers is a small computer assembly company. Any customer currently has the
following choices for a PC:
(i) 800 MHz processor, 40 GB HDD, 128 MB RAM
(ii) 1 GHz processor, 60 GB HDD, 256 MB RAM
(iii) 1.2 GHz processor, 80 GB HDD, 512 MB RAM
The use of what design pattern would ensure that only the legal combinations
could be sold?
A Factory Method
B Builder
C Prototype
D Abstract Factory
E Singleton
Choice D is correct.
This question needs you to apply your knowledge of design patterns. We are
dealing with families of related objects.
Abstract Factory (GOF 87)"Provide an interface for creating families of
related or dependent objects without specifying their concrete classes."
The applicability section of Abstract Factory (GOF 88) indicates that this
pattern is to be used when:
A system should be
configured with one of multiple families of products
A family of related
product objects is to be used together and the constraint needs to be
enforced.
Hence Abstract Factory is the right pattern for this problem. Choice D is
therefore 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." Hence choice A 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." Hence choice B is incorrect.
Prototype (GOF 117)" Specify the kinds of objects to create using a
prototypical instance, and create new objects by copying this prototype."
Hence choice C is incorrect.
Singleton (GOF 127)" Ensure a class only has one instance, and provide a
global point of access to it." Hence choice E is incorrect.
228 Inaccu Weather
has a web site where people can check the weather forecast of a city for up to
five days in advance. The data comes to Inaccu Weather through a specialized
custom feed that directly updates a relational database. If the company can
expect between fifty to hundred concurrent hits in to their site, which of the
following Java based technologies may be best suited for their needs?
A Servlets and JSP for
presentation and Session Beans with DAO for retrieval.
B Servlets and JSP for
presentation and CMP Beans for retrieval
C Servlets and JSP for
presentation and BMP Beans for retrieval
D Applets for presentation and
either Entity or Session Beans for retrieval
E Servlets and JSP for
presentation with Java classes encapsulating all database access.
Choice E is correct.
The key points are:
Low traffic that this site will be encountering
The fact that the data is not modified through the site. All database access
is going to be for simple read-only data.
From these points we can summarize that the use of EJBs will be overkill for
such a simple application. However you still do not want to embed data access
logic directly into Servlets, as that would not be a very modular approach.
Hence use Servlets and JSP for presentation and Java classes to encapsulate
interactions with the database. Choice E is therefore correct.
While choice A is a straightforward Model2 technique for this system, the use
of EJB is not required here. Hence choice A is incorrect. Note that if the
traffic becomes much higher and they wish to migrate to an EJB solution,
choice A would become the best candidate.
We have discussed that the use of EJB is not necessary for this application.
Further there is no concurrent use of shared data. Hence Entity beans are
definitely not the ideal choice. Choice B and C are therefore incorrect.
Choice D indicates the use of Applets and EJB. Applets are best used when
better GUI capability is required. In this example, JSP is a perfectly good
solution. In any case, this choice refers to the use of EJB (already discussed
as extra baggage for this problem.) Hence choice D is incorrect.
229 Toysrfuss, a
national toy store is creating a new e-front for Order processing. Customers
have to create an account to transact with them, although an account is not
required for browsing the catalog. Customers can browse items and add them to
a shopping cart. They can then proceed to checkout. At this time, they can
update quantities and submit the order. What technologies may be best suited
for this application?
A JSP for presentation and
Servlets as controllers.
B Servlets for presentation and
JSP as controller.
C Stateless Session Bean for
Shopping cart
D Stateless session bean for
catalog retrieval.
E Stateful Session bean for
shopping cart.
F Stateful session bean for
Order update.
G Entity bean for Catalog
retrieval
H Entity bean for Order update.
Choices A, D, E and H are correct.
The use of JSP for presentation and Servlets for controllers is consistent
with the Model 2 approach. Hence A is a right choice.
Choice B is the opposite of choice A and therefore incorrect.
Choice C is incorrect because it is suggesting the use of a Stateless Session
bean for the management of the shopping cart. Since stateless beans do not
maintain any conversational state, they cannot be used for this purpose.
The use of a stateless session bean for catalog retrieval is consistent with
the Model 2 architecture and a recommended best practice. Choice D is
therefore correct.
Stateful Session Beans hold conversational state. Hence the management of a
shopping cart is a good example of their use. E is therefore correct.
Stateful Session beans are not very useful for updating order information. F
is therefore incorrect.
Entity beans for catalog retrieval are overkill because Entity beans are best
used when shared data is being concurrently accessed or heavy transactional
DML statements are required. G is therefore incorrect.
Entity beans represent the enterprise data of a system and perform specialized
DML operations like inserts, deletes and updates. They would be perfect for
updating order information. H is therefore a correct choice.
230 Of the
following scenarios, which one may be best suited for the use of Entity
Enterprise Beans?
A Calculation of tax
information, based on data retrieved by two other Entity Beans
B To maintain shopping cart
state for an online application
C To retrieve product catalogs
based on a search criteria
D To allow concurrent access to
shared data, as in the case of on an online auction house's application.
Choice D is correct.
While Entity beans model business concepts, usually persisted as records in
some kind of database, it is not necessary to use Entity beans every time you
interact with the database. In fact from a performance point of view, simple
selects and retrieval can be just as easily done using Session Beans with Data
Access Objects (DAO.) Entity Beans are best used when you are dealing with
concurrent access to shared data, where transactions, concurrency and
integrity play a vital role. Hence choice D is correct.
Choice A refers to using existing data and performing some calculation on it.
This can be best achieved through a Stateless Session Bean. Hence choice A is
incorrect.
Choice B talks about maintaining conversational state. This is best dome with
Stateful Session Beans. Hence choice B is incorrect.
Retrieval of product catalogs is a simple query. Again this can be done
through Stateless Session Beans and DAO. Hence choice C is incorrect.
231 Most EJB
servers show high degree of availability. Server clusters are an example of
how this is functionality is achieved. What key advantages might server
clusters offer in an EJB environment?
A Load distribution
B Location transparency
C Caching capability
D Load balancing capability
E 2PC (Two phase commit)
capability
Choices A and D are correct.
Server clusters increase availability and redundancy in a system. They also
provide fault tolerance. With clusters, requests can be distributed so that
multiple servers share the load. Some servers may also offer the
sophistication to determine which servers are under utilized so that load can
be balanced. Hence choices A and D are correct.
Location Transparency is achieved through Object Distribution. This is a
feature of all distributed systems. Hence choice B is incorrect.
Various vendors may offer a variety of tools for better resource management.
Caching may be one such capability. It has nothing to do with a multi-server
environment though. Hence choice C is incorrect.
Two phase commit (2PC) may be a feature offered by many J2EE vendors for
addressing distributed transactions. Again this is not a feature of server
clustering. Hence choice E is incorrect.
232 Status Quo is
an emerging B2C company that has a portal through which customers can purchase
clay jewelry. Since the order process involves a shopping cart, session
management and secure access are required. How would you manage this?
A Use HTTP since it is a
stateful protocol
B Use HTTPS since it is a
stateful protocol
C Use SOAP for state and
security management.
D Use CGI with cookies for state
management.
Choice B is correct. HTTPS is a secure and stateful protocol.
Choice A is incorrect because HTTP is inherently stateless.
Choice C is incorrect because SOAP is an RPC mechanism, not a state management
mechanism.
Choice D is incorrect because CGI programs are server side processes
(comparable to Java Servlets.) They do not manage session state.
233 Chocolat, an
exotic chocolate maker in
France is
planning to provide an e-front for chocolate sales. FedEx would ship the
packages to various national and international locations. In order to
customize the customer's interaction with the system and to make his / her
overall shopping experience more pleasant, Chocolat has decided to support
Internationalization.
What are some of the common things they would need to consider?
A Language for messages.
B Formats (numeric, date and so
on.)
C DMZ requirements
D Taxes and legal rules.
E RSA
F MD5
Choices A, B and D are correct.
This question deals with Internationalization. Language for messages, formats
(numbers, date and so on), taxes and legal rules are all subject to
Internationalization. Hence A, B and D are correct.
Choice C refers to a security mechanism where a demilitarized zone is created
between two firewalls and is irrelevant to I18N. RSA and MD5 are security
terminology used with cryptography. Therefore choices E and F are incorrect.
234 A sample
program ships with 2 properties files - Base.properties, Base_fr.properties.
If the current Locale, Locale.ENGLISH has no matching properties file, what
will happen when the ResourceBundle.getBundle method is called with 'Base' and
Locale. English as parameters?
A Since a matching properties
file is not found, an exception is thrown
B This would not pose a problem
because when a matching properties file is not found, the default properties
file is used instead.
Choice B is correct.
When the getBundle() method is called on ResourceBundle, it checks to see if a
class or property file is available for the base parameter's current locale.
If neither is available, it uses the default. In this case Base.Properties
will be used. Hence choice B is correct.
235 What is a
Demilitarized Zone (DMZ)?
A The logical separation of
tiers in a J2EE application. Example: the separation between the Web Tier and
the EJB Tier
B The logical separation of
layers in a J2EE application. Example: The separation between the Operating
System and the EJB Container.
C A type of protection offered
by proxy firewalls, currently only available to the U.S armed forces under
National Security laws.
D The region between two
firewalls
Choice D is correct.
Demilitarized Zone (DMZ) is an area between two firewalls. The outer firewall
lets requests to publicly accessible services in. It will reject all other
requests. The inner firewall will protect the company's internal network and
prevent requests coming into the DMZ from passing through it. Choice D is
therefore correct.
Choices A, B and C are all incorrect.
236 ScreamWorks, a
cinema multiplex, has a website from which you may download signed applets
with the latest trailers, show timings and so on. The Applet works on Java 1.3
or higher. The applet needs to write user preferences to a temp file in the
host machine (where it is being executed). Is that possible? Note that the
client has defined a usePolicy and the java.policy has granted no persmissions
for the applet
A Applets cannot be used here
because even signed applets are untrusted if the necessary permissions are not
granted
B The sandbox model does not
apply to signed applets. Hence this will pose no problem.
Choice A is correct.
This question expects you to be familiar with the changes in the Java 2
Security model. In JDK1.2 and higher, all code local and remote can be
subjected to a security policy. By default, remote code will be constrained to
the old Sandbox model. However if a policy file is created with grant
privileges, an applet will be restricted to the grants whether or not it is
signed. Hence choice A is correct.
237 Which of the
following are valid methods in Entity EJBs?
A ejbActivate()
B observe()
C ejbRetrieve()
D ejbStore()
E ejbDestroy()
F ejbRemove()
Choices A, D and F are correct. Entity Beans are subject to activation and
Passivation. The container informs the bean that the bean is about to be
passivated or activated through the two callback methods - ejbPassivate() and
ejbActivate(). EjbStore() is a callback method used during database
synchronization. EjbRemove() is called when the client wishes to remove the
data the bean represents, from the database. Hence choices A, D and F are
correct.
EjbSave(), ejbRetrieve() and ejbDestroy() are not valid methods for EJBs.
Hence choices B, C and E are incorrect.
238
What does the term Atomicity
mean in the context of ACID transactional properties and Enterprise Java
Beans?
A Integrity of underlying data
B Non Interference from other
processes or systems
C Complete execution or no
execution at all
D Maintenance of all data
changes in physical storage
Choice C is correct.
Atomicity (Monson-Haefel 2nd edition 275)"To be atomic, a transaction must
execute completely or not at all." Hence choice C is correct.
Choice A refers to 'Consistency.' Hence it is incorrect.
Choice B refers to 'Isolation.' Hence it is incorrect.
Choice D refers to 'Durability.' Hence it is incorrect.
239 Which of the
following statements about 'Not Supported' and 'Never' transactional
attributes are true?
A Not Supported' suspends any
transaction until the method is completed whereas 'Never' throws a
RemoteException when called with a transaction.
B Never' suspends any
transaction until the method is completed whereas 'Not Supported' throws a
RemoteException.
C If the method is called
without any transactional scope, both attributes will work identically.
D If the method is called with a
transactional scope, both attributes will work identically.
Choices A and C are correct.
Choice A describes how the transactional attributes 'Not Supported' and
'Never' work. A is therefore correct.
B is the inverse of A and therefore incorrect.
C describes a situation where a method with transactional attribute 'Not
Supported' or 'Never' is called without a transactional scope. In this case
they both behave identically. Choice C is therefore correct.
Choice D indicates that under both circumstances the method will execute
identically. This is incorrect because a 'Never' method will throw a
'RemoteException' if called with a transaction. D is therefore incorrect.
240 EJB1.1 has
support for undefined Primary Keys. This means that the Primary Key can be
undefined until deployment time. When we use defined Primary Keys, the Bean
class and the Interfaces use the BeanPK type to identify the key.
What do the Bean class and the Interfaces refer to in
the case of undefined Primary Keys?
A Though the Primary Key itself
can be undefined, its name must be predetermined. The Bean class and the
Interfaces use this name.
B An instance of
java.util.Enumeration
C An instance of java.lang.Class
D An instance of
java.lang.Object
Choice D is correct.
EJB 1.1 has support for undefined Primary Keys, which means that they can be
deferred until deployment time. When undefined Primary Keys are used, the Bean
class and its interfaces can refer to the undefined key using
java.lang.Object.
Choice A gives some incorrect information to throw you off.
Choices B and C are incorrect because you cannot use java.lang.Enumeration or
java.lang.Class for referring to undefined Primary Keys.
241 Which of the
following statements is true about DNS Round Robin?
A It considers actual load on
machines before routing requests.
B It uses a random generator to
decide which server to route a request to.
C It routs requests to one
server until a configured threshold is reached and then sends subsequent
requests to the next server.
D Each Request is sent to
subsequent server in the list, after the end is reached it starts with the
first server again.
Choice D is correct.
DNS Round Robin is a method is load distribution by which a set of servers is
allowed to process incoming requests in sequence. The first request goes to
the first server, the second to the second server and so on. When the end is
reached, the next request starts from the first server again. Hence choice D
is correct.
Note that DNS Round Robin is a good load distribution technique, not a load
balancing technique. Since requests get processed sequentially in DNS Round
Robin, the current load on a server is not taken into account before a new
request is delegated to a server. In load balancing techniques however, the
load on individual servers is monitored before additional requests are sent to
them. Hence choice A is incorrect.
DNS Round Robin allows servers to process requests sequentially, not in a
random fashion. Hence choice B is incorrect.
With load balancing techniques, a load monitor may check for the current load
on a primary server before deciding to delegate subsequent requests to another
server. This is not true of DNS Round Robin though. Hence choice C is
incorrect.
242 Generally
speaking what is the relevance between Performance and Security?
A They are not related to each
other in any way t4High Security generally results in high performance
B High performance is a
pre-requisite for secure systems
C Security and Performance are
inversely proportional
D Low performance systems cannot
be secure
Choice D is correct.
One of the key aspects of security is encryption and decryption of data. Data
encryption ensures that sensitive data will be protected against eavesdropping
and tampering. A concept called 'cryptography' is used for accomplishing this.
The two popular types of cryptography are 'Public Key Cryptography' or
'Asymmetric Key Cryptography' and 'Symmetric Key Cryptography.' In both forms,
a combination of Cryptographic algorithms (ciphers) and hashing algorithms
protect the data from intruders. The data is decrypted at the receiver's end
and becomes intelligible again. All this work results in extra overheads.
Hence generally increased security results in a lower performance. Choice D is
therefore correct.
Higher security results in lower performance. Hence choices A and B are
incorrect.
A high performance is not a technical pre-requisite for secure systems
although it may be a good idea to increase performance wherever possible to
offset the performance loss due to higher security. Hence choice C is
incorrect.
Many poorly engineered secure systems exhibit poor performance. Hence choice E
is incorrect.
243 Refer to the
following diagram:
In the above diagram:
A A has an association
relationship with C
B C has an association
relationship with A
C A has a composition
relationship with C
D C has a composition
relationship with A
E A has an aggregation
relationship with C
F C has an aggregation
relationship with A
Choice E is correct.
Aggregate relationship in UML is denoted with an open diamond on one side of
an association relationship. In the above diagram, class A has an aggregate
relationship with Interface C. Generally this means that at runtime, class A
will hold a reference to an object that implements Interface C. Hence choice E
is correct.
The interface C does not have an association, aggregation or composition
relationship with class A. Choices B and D and F
are therefore incorrect.
If class A had a solid diamond instead of an open diamond, it would have
represented a composition. Hence choice C is incorrect.
244 Refer to the
following exhibit:
The above diagram is an example of:
A Object Interaction Diagram
B Collaboration Diagram
C State Diagram
D Sequence Diagram
E Activity Diagram
Choice D is correct.
The diagram shown above represents a Sequence diagram. A sequence diagram is
an interaction diagram that shows the time ordering of events. Choice D is
therefore correct.
245 CORBA
specification does not provide support for which of the following?
A Naming Service
B Container managed Persistence
C Security
D Transaction Service
E Event (Asynchronous Messaging)
F Concurrency Control
Choice B is correct.
CORBA does not provide support for 'Container Managed Persistence.' CMP is a
concept only supported by the EJB specification. Hence choice B is correct.
CORBA has support for Naming, Security, Transactions, Events and Concurrency
control. Hence the other choices are incorrect.
246 Company ABC has
a legacy application that can be accessed via CORBA. The company wants to
integrate new Java based development with the existing legacy services. At
this time no new services are planned. If the legacy application were
primarily to be used as a CORBA server, which connectivity option would you
recommend?
A RMI-JRMP
B RMI with JNI
C Java IDL
D RMI-IIOP
E HTTP tunneling
Choice C is correct.
The key here is that the existing legacy system supports a CORBA interface and
no new services are being currently planned. If Java code is primarily going
to access CORBA services, the recommended connectivity tool is Java IDL. Java
IDL gives Java code CORBA capability. Hence choice C is the correct answer.
RMI-JRMP should be used when dealing with distributed applications, all
written primarily in Java. Hence choice A is incorrect.
The question does not specify anything about the legacy code's JNI capability.
However it specifically mentions about CORBA compatibility. Hence choice B is
incorrect.
RMI-IIOP is the protocol used with EJB. The legacy system is coded with a
CORBA interface and the question mentions that no new coding is anticipated.
So EJBs are not a good choice for this problem. Hence choice D is incorrect.
When you wish to communicate with a system whose firewall does not permit
requests of a certain protocol, the requests are sometimes masqueraded as HTTP
requests. This concept is called HTTP tunneling. Hence choice E is incorrect.
247 Which of the
following defines a standard architecture for connecting the J2EE platform to
heterogeneous EIS applications?
A J2SE
B Java Web Start
C JDBC
D JMS
E JCA
Choice E is correct.
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 correct.
J2SE is a platform that provides"the compiler, tools, runtimes and APIs for
developing, deploying and running applets and applications in the Java
programming language." Hence choice A is incorrect.
The following is taken from:
http://java.sun.com/products/javawebstart/
"Java TM Web Start -- a technology for simplifying deployment of Java
applications-- gives you the power to launch full-featured applications with a
single click from your Web browser. You can now download and launch
applications, such as a complete spreadsheet program or an Internet chat
client, without going through complicated installation procedures." Hence
choice B is incorrect.
The following is taken from:
http://java.sun.com/products/jdbc/
"JDBCTM technology is an API that lets you access virtually any tabular data
source from the Java TM programming language. It provides cross-DBMS
connectivity to a wide range of SQL databases, and now, with the new JDBC API,
it also provides access to other tabular data sources, such as spreadsheets or
flat files.
The JDBC API allows developers to take advantage of the Java platform's "Write
Once, Run Anywhere TM" capabilities for industrial strength, cross-platform
applications that require access to enterprise data. With a JDBC
technology-enabled driver, a developer can easily connect all corporate data
even in a heterogeneous environment." Hence choice C is incorrect.
The following is taken from:
http://java.sun.com/products/jms/
"The JMS API improves programmer productivity by defining a common set of
messaging concepts and programming strategies that will be supported by all
JMS technology-compliant messaging systems." While you may be able to
communicate with EIS systems using JMS (if the EIS supports JMS), it is not a
standardized architecture for connecting to heterogeneous EIS applications.
Hence choice D is incorrect.
248 Which of the
following methods is optional in the Home Interface of an Entity Bean?
A Create()
B FindByPrimaryKey()
C Remove()
D None of the above
Choice A is correct.
Sometimes when you do not want the clients of an EJB application to add data
to your system, you may choose not to provide a create method in the Home
Interface of the Enterprise bean. The create method is therefore optional.
Hence choice A is correct.
249 The Bean class
provides implementations for which of the following methods?
A Methods in the Bean's Home
Interface
B Methods in the Bean's Remote
Interface
C EJB Callback methods
D A, B and C
E A and B
F A and C
G B and C
Choices A, B and C are correct.
The Bean class has implementations for the methods corresponding to the
methods in the Home and Remote Interfaces, and the bean's callback methods.
Hence choice D is correct.
250 Which of the
following statements is true about Stateful Session Beans?
A They leave Method Ready Pool
state to enter Does not Exist State.
B They leave Method Ready state
to enter Stateful State.
C They leave Method Ready state
to enter Passivated or Does not Exist state.
D They never leave the Method
Ready state.
Choice C is correct.
The valid lifecycle states of a Stateful Session Bean are Does Not Exist,
Method Ready, Method Ready (in TX) and Passive. The Bean instance leaves the
Method Ready state to enter the Passive State (through Passivation) or the
Does Not Exist State (through removal). Hence choice C is correct.
Method Ready Pool is not a valid state for Stateful Session Beans because the
specifications do not mandate the container to maintain a bean pool for
Stateful Session Beans. Note that some containers may internally use some kind
of pooling mechanism for achieving higher performance. Hence choice A is
incorrect.
There is no Stateful State in the lifecycle of a Stateful Session Bean. Choice
B is therefore incorrect.
Stateful Beans leave the Method Ready State to enter Does not Exist or Passive
State. Hence choice D is incorrect.
|