• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

OCMJEA Mock Exam – 11

February 5, 2014 //  by Krishna Srinivasan//  Leave a Comment

252 . 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?

Choose the one below:

  1. SomeOtherMethod also has to be use BMT since it’s part of the same bean
  2. SomeOtherMethod can use BMT or CMT, because transactions are defined at the method level in the
    deployment descriptor
  3. If SomeOtherBean is a Session Bean, it has to necessarily use BMT since the caller is a BMT method
  4. If SomeOtherBean is a Session Bean, it may use either BMT or CMT
  5. If SomeOtherBean is an Entity Bean, it may use either BMT or CMT
  6. If SomeOtherBean is an Entity Bean, it must necessarily use only CMT

253 . 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?

Choose the one below:

  1. True
  2. False

254 . 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?

Choose the one below:

  1. Adding capacity will improve scalability, as more memory would allow better bean pooling
  2. Adding a server would be difficult, as EJB servers cannot span multiple physical machines
  3. The proposal not does address horizontal scalability
  4. The proposal addresses both vertical and horizontal scalability
  5. Adding a server to the system would be easy as EJB vendors generally support fault tolerant mechanisms via server clustering

255 . 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?

Choose the one below:

  1. RMI/JRMP with JNI
  2. Java IDL
  3. RMI / IIOP
  4. JMS

256 . A firewall blocks all requests except those on ports 80 and 443. IIOP requests?

  1. Can be processed because IIOP always works on port 80
  2. Cannot be processed because port 80 belongs to a different protocol
  3. Can be processed by SSL
  4. Can be processed via HTTP blocking
  5. Can be processed via HTTP tunneling

257 . Applications exchange messages through?

  1. Active channels called Networks
  2. Active Channels called Message Brokers
  3. Virtual Channels called Digests
  4. Virtual Channels called Destinations

258 . Which of the following are true about Publish/Subscribe?

  1. Subscribers receive a copy of every message
  2. It is a Pull (Polling) based model
  3. It is a push-based model
  4. It is generally used when one publisher wishes to send a message to one subscriber

259 . In the Publish/Subscribe messaging architecture, publishers send messages to?

  1. A specified node, which is then re-distributed to all subscribers
  2. Directly to all subscribers in the Topic subscription list
  3. A designated queue
  4. A component transaction monitor such as an EJB Server for further processing by a message driven bean

260 . 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?

Choose the one below:

  1. True
  2. False

261 . Which of the following are not true about N-Tier Systems?

  1. N-Tier systems are distributed over many systems and hence always present a maintenance problem
  2. N-Tier systems are generally component based and are therefore quite easy to maintain
  3. Since N-Tier systems do not use database stored procedures or triggers for business logic processing, they are generally very slow
  4. Since N-Tier systems are container based, many N-Tier systems can be easily scaled (both vertically and horizontally)
  5. 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
  6. N-Tier systems can use various techniques for Identification, Authentication and Authorization and are therefore considered quite secure

262 . 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?

Choose the one below:

  1. True
  2. False

263 . Which of the following do not aid a system’s extensibility?

  1. Modularizing Code
  2. Using well defined software design patterns
  3. Using Servlets to manage distributed database access
  4. Using JSP Scriptlets to locate Enterprise beans
  5. Using Data Access Objects when Session Beans or BMP Entity beans have to communicate to the database

264 . Refer to the following diagram?

In the UML diagram,

Choose the one below:

  1. ‘A’ has an association relationship with ‘B’
  2. ‘B’ has an association relationship with ‘A’
  3. ‘A’ extends ‘B’
  4. ‘A’ has a composition relation with ‘B’
  5. ‘B’ has a composition relationship with ‘A’
  6. ‘A’ has an aggregation relationship with ‘B’
  7. ‘B’ has an aggregation relationship with ‘A’

265 . Refer to the following diagram?

What UML diagram is shown in the figure?

Choose the one below:

  1. Class
  2. Object
  3. Component
  4. Collaboration
  5. Sequence
  6. Package
  7. Node

266 . Which of the following statements about Interaction diagrams are true?

  1. Interaction diagrams represent the dynamic view of a system
  2. Interaction diagrams may represent static or dynamic views of the system
  3. Interaction diagrams are polymorphic
  4. Interaction diagrams are isomorphic
  5. Interaction diagrams only show time ordering of messages
  6. Interaction diagrams may show the structural organization of the objects that send or receive
    messages

267 . Refer to the following diagram?

From the diagram, it can be inferred that?

Choose the one below:

  1. A can only have 2 or 4 Bs associated with it
  2. A can have 2 to 4 (4 not inclusive) Bs associated with it
  3. A can have 2 to 4 (2 not inclusive) Bs associated with it
  4. A can have either 2 or 4 Bs associated with it but not 3
  5. A can have 3 Bs associated with it

268 . 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 choice here?

Choose the one below:

  1. Since Metallic will not let CORBA requests through, Nopester should continue sending faxes
  2. Nopester should take its business away to Metallic’s competitors
  3. Nopester should use the popular SOAP protocol since SOAP requests communicate over HTTP
  4. Nopester should use a concept called HTTP tunneling to communicate with Metallic

269 . 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?

Choose the one below:

  1. Rewrite the system using Applets
  2. Rewrite the system using Model2 Architecture based solution
  3. Use screen scraper for obtaining an object interface and off-board server for forwarding requests
  4. Use RMI with JNI. To Enable HTTP tunneling and use CORBA calls

270 . 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?

Choose the one below:

  1. Iterator
  2. Mediator
  3. Interpreter
  4. State
  5. Singleton

271 . 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?

Choose the one below:

  1. Composite
  2. Flyweight
  3. Template Method
  4. Command
  5. Memento
  6. Chain of Responsibility

272 . 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?

Choose the one below:

  1. Service to Worker
  2. Fast Lane Reader
  3. Observer
  4. Visitor
  5. Publish/Subscribe

273 . 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 ?

  1. Interpreter
  2. Visitor
  3. Mediator
  4. Service Locator
  5. Service to Worker

274 . 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:

  1. Processor – 800Mhz, 1Ghz, 1.2Ghz
  2. HDD – 40 GB, 60 GB, 80 GB
  3. 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?

Choose the one below:

  1. Factory Method
  2. Prototype
  3. Singleton
  4. Template Method
  5. Business Delegate
  6. Builder

275 . 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?

  1. Java Servlets
  2. JSP with Java classes
  3. CMP Entity Beans
  4. BMP Entity Beans
  5. Stateless Session Beans with DAO
  6. Stateful Session Beans with DAO

276 . 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?

Choose the one below:

  1. Java-IDL
  2. RMI-JRMP
  3. EJB
  4. JTA/JTS
  5. JCA
  6. JMS
  7. JAF

277 . Which of the following situations may be best suited for implementation using Servlets and JSP?

  1. Need large scale deployment
  2. Need heavy use of transactions
  3. Need to process dynamic requests from HTTP clients
  4. Need access to relational databases through a generic set of APIs
  5. To function as Intercepting filters, request processors and request dispatcher
  6. When static templates are combined with data to form dynamic HTML output

278 . What are the benefits of Bean pooling?

  1. Bean instances are created during startup, thus avoiding the expense of creation, each time a client requests it
  2. Bean pooling allows load distribution over several machines
  3. Bean pooling is the container’s way of balancing load – moving future requests from client to a different machine, if load increases are encountered
  4. Allows a container to use beans as flyweights

279 . What are the valid life-cycle states an Entity Bean can exist in?

  1. Does Not Exist, Pooled, Method Ready
  2. Does Not Exist Ready, Ready (in TX), Passivated
  3. Does Not Exist, Method Ready Pool
  4. Does Not Exist, Pooled, Ready

280 . 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?

Choose the one below:

  1. RMI-JRMP with JNI wrappers for the API calls
  2. RMI-IIOP (Stateless session beans making the API calls)
  3. Custom socket programming to replace the C++ daemon process with a Java class
  4. HTTP request making a CGI call for the Billing updates
  5. JINI based program to interface to the APIs
  6. JCA to make the API call

281 . Which of the following statements are true?

  1. The java.text package contains classes and interfaces for handling text in a locale-sensitive way
  2. The java.text package contains the Locale class and classes for Date and Time
  3. The java.util package contains classes for importing and exporting non-Unicode character data
  4. The java.util package contains the Locale class and classes for Date and Time

282 . The representation of a set of cultural and language preferences is done using which class?

  1. java.util.LanguagePreference
  2. java.text.MessageFormat
  3. ResourceBundle
  4. Locale

283 . What is the difference in the Java Security model between JDK 1.1 and JDK1.2 with regards to applets?

  1. There is no difference between the two JDK versions in question. Applets are always confined to the sandbox
  2. In JDK 1.1, applets are never trusted and in JDK 1.2 they always are
  3. 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
  4. In JDK 1.1 only signed applets were trusted whereas in JDK 1.2, any applet with the right security permissions can be trusted

284 . Which of the following are mandatory steps in the SSL handshake?

  1. Validate Client to Server
  2. Validate Server to Client
  3. Allow client and server to choose cryptographic algorithm
  4. Use symmetric key encryption to generate shared secrets

285 . When a Stateful Session Bean is passivated, what activities should the developer perform in the ejbPassivate() method?

  1. Close all open resources
  2. Set transient fields to NULL
  3. Set Non-transient fields to NULL
  4. Set non-transient non-serializable fields to NULL

286 . 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?

  1. Supports
  2. Required
  3. Not Supported
  4. Requires New
  5. Mandatory
  6. Never

287 . The findByXxx() method in the Home Interface of an entity bean returns?

  1. An Instance of java.lang.Object
  2. An instance of the Remote Reference to the bean
  3. An instance of java.util.Enumeration
  4. An instance of the Bean class

288 . With Bean Managed Persistence, what are the developer’s responsibilities in terms of data
synchronization?

  1. 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
  2. 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

289 . Under which of the following conditions should you use an Entity Bean?

  1. The bean represents a business entity, not a procedure
  2. 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)

Choose the one below:

  1. Choice (1) only
  2. Choice (2) only
  3. Choice (1) or (2) depending on whether the Container is EJB 1.0 compliant or EJB 1.1 compliant
  4. Both choice (1) and (2)

Answers

252 : 1,4 & 6 is correct.
Explanation:
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 1 is correct.

Session Beans may either be defined as CMT beans or BMT beans whereas Entity beans can only be CMT beans. Hence choices 4 and 6 are correct.

The same bean cannot have both BMT and CMT transaction management. Hence choice 2 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 3 is incorrect.

Entity Beans can only be CMT beans. Hence choice 5 is incorrect.

253 : 2 is correct.
Explanation:
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.

254 : 1,4 & 5 is correct.
Explanation:
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 1, 4 and 5 are correct.

Most J2EE vendors provide multi-server support. Hence choice 2 is incorrect.

Adding a new server is an example of Horizontal scalability. Hence choice 3 is incorrect.

255 : 3 is correct.
Explanation:
The key here is that ABC Inc. is using a primarily EJB based application. The protocol used in EJB is RMI-IIOP. Hence choice 3 is correct.

The question clearly says that the existing application is in EJB. There is no legacy connectivity involved here. Hence choice 1 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 2 is incorrect.

JMS is useful when you want to send messages to other applications asynchronously via a Message Oriented Middleware. Hence option 4 is incorrect as well.

256 : 5 is correct.
Explanation:
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 5 is correct.

Port 80 is the standard port for HTTP requests, not CORBA requests. Hence choice 1 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 2 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 3 is incorrect.

While firewalls may block requests of certain protocols, there is no concept called HTTP blocking. Hence choice 4 is incorrect.

257 : 4 is correct.

258 : 1 & 3 is correct.
Explanation:
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 1 and 3 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 2 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 4 is incorrect.

259 : 1 is correct.
Explanation:
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 2 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 3 is incorrect because it refers to the Point-to-Point messaging model, which is typically a one to one communication between two parties.

Choice 4 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.

260 : 2 is correct.
Explanation:
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 2 is correct.

261 : 1,3 & 5 is correct.
Explanation:
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 1 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 3 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 5 is a right answer.

2, 4 and 6 are good examples of other capabilities of N-Tier systems.

262 : 2 is correct.
Explanation:
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.

263 : 3 & 4 is correct.
Explanation:
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 3 and 4 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.

264 : 4 is correct.
Explanation:
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.

265 : 6 is correct.
Explanation:
The diagram denotes a package diagram. A package diagram (Fowler 108) shows packages of classes and the dependencies among them. Choice 6 is correct.

266 : 1,4 & 6 is correct.
Explanation:
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 1, 4 and 6 are correct.

Interaction diagrams do not describe the static view of a system. Hence choice 2 is incorrect.

Interaction diagrams are isomorphic, nor polymorphic. Hence choice 3 is incorrect.

Interaction diagrams show either the time ordering of messages (sequence diagrams) or the structural organization of objects (collaboration diagrams.) Hence choice 5 is incorrect.

267 : 5 is correct.
Explanation:
The multiplicity shown above translates into (A can have 2 to 4 Bs associated with it.) Choice 5 says that A can have 3 Bs associated with it and is therefore correct.

268 : 4 is correct.
Explanation:
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 4 is correct.

Choice 1 is incorrect for obvious reasons. What is the point of automation if we still want to use a paper based solution?

Choice 2 is incorrect because businesses do not change partners due to minor software issues.

Choice 3 is incorrect because there is no mention of whether Metallic supports SOAP in the discussion.

269 : 3 is correct.
Explanation:
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 3 is therefore correct.

Rewriting the system is time consuming and also cost intensive. Hence choices 1 and 2 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 4 is incorrect.

There is also no mention of CORBA support. Hence choice 5 is incorrect.

270 : 5 is correct.
Explanation:
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 5 is correct.

Iterator (GOF 257)”Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.” Hence choice 1 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 2 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 3 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 4 is incorrect.

271 : 5 is correct.
Explanation:
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 5 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 1 is irrelevant here and therefore incorrect.

Flyweight (GOF 195)”Use sharing to support large numbers of fine-grained object efficiently.” Hence choice 2 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 3 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 4 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 6 is therefore incorrect.

272 : 3 is correct.
Explanation:
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 3 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 1 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 2 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 4 is therefore incorrect.

Publish/Subscribe is a messaging architecture, not a design pattern. Hence choice 5 is incorrect.

273 : 3 is correct.
Explanation:
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 3 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 1 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 2 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 4 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 5 is therefore incorrect.

274 : 2 is correct.
Explanation:
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 2 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 1 is incorrect.

Singleton (GOF 127)” Ensure a class only has one instance, and provide a global point of access to it.” Hence choice 3 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 4 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 5 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 6 is incorrect.

275 : 5 is correct.
Explanation:
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 5 is correct.

Choice 1 and 2 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 3 and 4 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 6 is incorrect.

276 : 6 is correct.
Explanation:
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 6 is correct.

Java-IDL, RMI-JRMP and EJB are used for synchronous communication. Hence choices 1, 2 and 3 are incorrect.

JTA/JTS is used to manage user-defined transactions and is irrelevant to this discussion. Hence choice 4 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 5 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 7 is incorrect.

277 : 3,5 & 6 is correct.
Explanation:
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 3, 5 and 6 are correct.

When an application involves large-scale deployment and heavy transactional requirements, EJBs are the best technology. Hence choices 1 and 2 are incorrect.

JDBC is used to access relational databases through a generic set of APIs. Hence choice 4 is incorrect.

278 : 1 & 4 is correct.
Explanation:
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 1 and 4 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 2 and 3 are incorrect.

279 : 4 is correct.
Explanation:
The valid lifecycle states for an Entity Bean are Does Not Exist, Pooled and Ready. Hence choice 4 is correct.

Entity Beans do not have a Method Ready state. Hence choice 1 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 2 is incorrect.

The Method Ready Pool state is a lifecycle state for Stateless Session Beans, not Entity Beans. Hence choice 3 is incorrect.

280 : 1 is correct.
Explanation:
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 1 is correct.

The question says that the billing system only supports C++ APIs. Hence choice 2 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 3 is incorrect.

HTTP, JINI and JCA do not satisfy the requirement of the C++ wrapper need. Hence choices 4, 5 and 6 are also incorrect.

281 : 1 & 4 is correct.
Explanation:
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 1 and 4 are correct.

The java.util package contains the Locale class and Date and Time classes. Hence choice 2 is correct.

The InputStreamReader and OutputStreamWriter classes handle non-Unicode character data conversion. These classes are found in the java.io package. Hence choice 3 is incorrect.

282 : 4 is correct.
Explanation:
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 4 is correct.

There is no LanguagePreference class. Regional preferences are addressed through various I18N features such as ResourceBundle, Locale and so on. Hence choice 1 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 2 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 3 is incorrect.

283 : 4 is correct.
Explanation:
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 4 is correct.

Choices 1, 2 and 3 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.

284 : 2 & 3 is correct.
Explanation:
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 2 and 3 are correct.

The client’s validation to the server is an optional step in the SSL handshake. Hence choice 1 is incorrect.

Public Key Cryptography is used to generate shared secrets. Hence choice 4 is incorrect.

285 : 1 & 4 is correct.
Explanation:
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 1 and 4 are correct.

There is no need to set transient fields to NULL. They will not be serialized anyway. Therefore choice 2 is incorrect.

If Non-transient fields are set to NULL, there is no point in serializing the bean instance. Hence choice 3 is incorrect.

286 : 3,4 & 6 is correct.
Explanation:
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 3, 4 and 6 are correct and choices 1, 2 and 5 are incorrect.

287 : 2 & 3 is correct.
Explanation:
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 2 and 3 are correct.

The finder methods never return an instance of java.lang.Object. Choice 1 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 4 is therefore incorrect.

288 : 2 is correct.
Explanation:
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 2 is correct.

Choice 1 is incorrect because it suggests that it is the client’s responsibility to invoke the callback methods.

289 : 4 is correct.
Explanation:
Entity Beans are best used when the bean represents a business entity and when the bean’s state must be persistent. Hence choice 4 is correct.

1. The bean represents a business entity, not a procedure.

2. 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).

Category: CertificationsTag: OCMJEA

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Previous Post: « OCMJEA Mock Exam – 10
Next Post: OCPJBCD Mock Exam -1 »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

New Features in Spring Boot 1.4

Difference Between @RequestParam and @PathVariable in Spring MVC

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact