JavaBeat Certifications Certifications Kits Articles Interview Questions OCAJP 7 OCPJP 5 OCPJP 6 OCEJWCD 6 SCBCD 5.0 SCEA SCJA

SCEA Mock Exams - 9

201   The Remote Interface of an Enterprise Bean extends from:

 

A     java.ejb.EJBRemote

B     javax.ejb.RemoteInterface

C     javax.ejb.EJBObject

D     javax.rmi.RemoteReference

 

Choice C is correct.

 

Remote Interfaces of EJBs extend from javax.ejb.EJBObject. Hence choice C is correct.

Though it sounds likely, A, B and D are incorrect because there is no interface called EJBRemote, RemoteInterface or RemoteReference.

 

 

 

 

202   Which of the following are not applicable to the Primary Key Class?

 

A     It must implement the java.io.Serializable interface

B     It must provide a default constructor

C     It must override hashCode() and equals()

D     Cannot be undefined if the PK is a Compound Primary Key

E     Primitive wrappers cannot be used when dealing with Single field keys

 

Choices D and E are correct.

 

The question says 'not applicable' and only choices D and E are not true. Compound Primary Keys can remain undefined until deployment time and primitive wrappers can be used with dingle field keys. Hence choices D and E are correct.

Choices A, B and C are true about Primary Keys and therefore incorrect choices.

 

 

 

 

203   Which of the following statements is true about Session Beans?

 

A     All attributes of a Stateless Session bean have to be set to null prior to passivation.

B     All non-transient and non-serializable fields of a Stateful Session Bean have to be set to null in the ejbPassivate() method.

C     The container uses Passivation on Stateful and Stateless Session Beans to allow pooling and swapping which are good techniques for resource management.

D     Passivation only applies to Entity Beans and not to Session Beans.

 

Choice B is correct.

 

When a bean is about to be passivated, the container calls the ejbPassivate() method. At this time, the bean instance can close all open resources and set all non-transient non-serializable fields to null. Hence choice B is correct.

Stateless Session Beans are not passivated. Hence choice A is incorrect. While Stateful Session Beans are pooled and swapped, Stateless Session Beans are not. Hence choice C is incorrect. In addition to Entity Beans, Stateful Session Beans are passivated as well. Hence choice D is incorrect.

 

 

 

 

 

204   When a call is made to a single-entity find method in an entity bean, the ObjectNotFoundException is thrown indicating that the requested entity was not found. What happens to the transaction?

 

A     It is automatically rolled back since it is an application exception.

B     It is not automatically rolled back since it is a system exception.

C     It is not automatically rolled back since it is an application exception.

D     It is automatically rolled back since it is a system exception.

E     It may or may not automatically rollback based on container specific implementation.

Choice C is correct.

 

The question deals with the ability to differentiate between system exceptions and application exceptions, and their impact on transactions. The container throws the ObjectNotFoundException to indicate that the entity requested by the single entity find method was not found. When this happens, the transaction is not typically rolled back. Hence choice C is correct.

Application exceptions are thrown in response to errors encountered in the processing of business logic. Application exceptions do not cause transactions to roll back. Hence choice A is incorrect.

The ObjectNotFoundException is not a system exception. Hence choice B is incorrect. Again choice D indicates that the ObjectNotFoundException is a system exception and is therefore incorrect. Choice E indicates that it is up to the container to either roll back the transaction or not, which is incorrect.

 

 

 

 

205   Which of the following services does the EJB Container provide?

 

A     Object Distribution

B     Life Cycle Management

C     Integrated Web Server and Servlet Engine

D     Just in Time management Java Runtime Engine

E     Transaction Management

 

Choices A, B and E are correct.

 

The EJB developer is only responsible to developing the core service that the component provides. All other services are decorations provided by the container. For example, the container provides object distribution via the Home Interface and Remote Interface implementations and manages the life cycle of Beans. It also provides transaction management capabilities. Hence choices A, B and E are correct.

Many popular EJB vendors provide a web server and a Servlet engine as well. But that is not a responsibility of the EJB Container. Hence choice C is incorrect.

Choice D, mentions something about just in time management JRE, irrelevant jargon meant to throw off the reader. Hence choice D is incorrect.

 

 

 

 

 

206   When a client calls the create() on a Stateless Session Bean's Remote Interface,

 

A     The newInstance() method is invoked by the container

B     The ejbCreate() method is called by the container

C     Passivated instance is activated and attached to the EJB Object

D     The Container takes an instance from the Method Ready Pool and attaches it to the EJB Object.

 

Choice D is correct.

 

With Stateless Session Beans, a new instance is not created each time a client request comes in. Instead, the container manages a pool of bean instances, and when a client requests the service (via a create method), an instance from the pool is assigned to service the request. Hence choice D is correct.

The newInstance() method and the ejbCreate() method are invoked by the container to set up the instances in the bean pool and are not called with each create() method called by the client. Hence choices A and B are incorrect.

Choice C is incorrect because Stateless Session Beans are not passivated or activated.

 

 

 

 

207   The container will synchronize an Entity Bean's state with the database,

 

A     After every setXxx() method

B     When a client calls the ejbLoad() or ejbStore() method

C     When the container thinks its appropriate based on various factors including the Transactional Context.

D     When the connection.flush() method is called.

 

Choice C is correct.

 

In CMP, the container automatically handles synchronization between the bean and the database. With BMP the developer is responsible for providing the logic for database synchronization. In both cases however, the container decides when the synchronization should occur, based on various activities such as transactions, concurrency and resource management. Hence choice C is correct.

 

It is not guaranteed that data will be synchronized after each set method. Again this is because the container decides when to synchronize data. Hence choice A is incorrect.

The methods ejbLoad() and and ejbStore() are considered callback methods - the container uses them to communicate with the entity when it is about to or just has synchronized database state. Hence clients do not make calls to these methods. Choice B is therefore incorrect.

There is no method called connectionFlush(). Hence choice D is incorrect.

 

 

 

208   The standard ports for HTTPS and HTTP are

 

A     21 / 110

B     80 / 443

C     443 / 80

D     21 / 119

 

Choice C is correct.

 

Although port numbers are configurable, the default ports for HTTPS and HTTP are 443 and 80. Hence choice C is correct.

Port 21 is used with FTP, port 110 is used with POP3 and port 119 is used with NNTP. Hence choices A and D are incorrect. Choice B has the port numbers in the reverse order. Hence choice B is incorrect.

 

 

 

 

209   A browser client C1 opens an SSL session with Server S1 on port 443. C1 then opens a new browser window and opens an SSL session with Server S2 (while the SSL session with S1 is active in the other browser window.) At the same time client C2 opens an SSL session with S1 on 443 as well. Which of the following statements are false?

 

A     Client C1 cannot be engaged in two SSL connections as the same time.

B     S1 cannot be engaged in two SSL connections on the same port at the same time.

C     C1 can have multiple SSL connections open at the same time.

D     S1 can have multiple SSL connections open at the same time.

 

Choices A and B are correct.

 

Note that the question asks you which choices are false. Since clients can simultaneously engage in multiple SSL connections (through different browser instances) and servers can support multiple concurrent SSL connections, only choices A and B are false and therefore the right answers.

 

Choices C and D are true and therefore incorrect.

 

 

 

 

 

210   Messaging is achieved by:

 

A     Synchronous tightly coupled communication between distributed components

B     Asynchronous loosely coupled communication between components

C     Using Stubs and Skeletons

D     Marshalling and unmarshalling of data

 

Choice B is correct.

 

Messaging is a middleware architecture that is used for asynchronous communication. This is generally achieved through a store-and-forward mechanism. All message producers and message consumers communicate to each other via a Message Oriented Middleware. Message consumers receive messages via a polling mechanism or a server-push mechanism. Hence choice B is correct.

Synchronous tightly coupled communication is a feature of RPC middleware applications. Hence choice A is incorrect.

Stubs and Skeletons are used to Marshall and unmarshall data in distributed RPC environments. Hence choices C and D are incorrect.

 

 

 

 

 

 

211   Messaging supports which of the following two models:

 

A     Point to Point

B     Envelope/Letter

C     Publish/Subscribe

D     Send to List

 

Choices A and C are correct.

 

There are two models available in Messaging. Point-to-Point is typically used for a one to one communication and Publish Subscribe is used when messages need to be broadcast to a group of subscribers. Hence choices A and C are correct.

The envelope-content is not a messaging paradigm. It is an example used to illustrate how messages are constructed when using Simple Object Access Protocol (SOAP.)  Hence choice B is incorrect.

There is no paradigm called Send to List. Publish Subscribe is used for one to many communication. Hence choice D is incorrect.

 

 

 

 

212   Which of the following is not true about RPC?

 

A     RPC attempts to mimic the behavior of a system that runs in one process

B     When a remote procedure is invoked, the caller is blocked until the procedure completes and returns control

C     RPC is asynchronous in nature

D     RPC is tightly coupled

 

Choice C is correct.

 

The question is asking what is false about RPC. Only choice C, which says that RPC is asynchronous in nature, is false. Therefore choice C is correct.

Choices A, B and D are true statements about RPC based communication and hence incorrect.

 

 

 

 

213   What is the difference between Maintainability and Manageability in Software Engineering?

 

A     Manageability is the ability to correct flaws in the system whereas maintainability is the ability to ensure the continued health of the system.

B     Maintainability is the ability to correct flaws in the system whereas manageability is the ability to ensure the continued health of the system.

C     Maintainability deals with ensuring that the system is always reliable and accessible whereas manageability deals with the ability to add functionality to the system.

D     They are both the same.

 

Choice B is correct.

 

Maintainability (Cade 8),"is the ability to correct flaws in the existing system without impacting other components of the system" and manageability (Cade 9)"is the ability to manage the system to ensure the continued health of a system with respect to scalability, reliability, availability, performance and security." Hence choice B is correct.

The definitions in choice A are in the reverse order and incorrect in choice C. Choice D is trying to say that the two non-functional requirements refer to the same thing. Hence they are all incorrect.

 

 

 

 

214   Which of the following are not considered tiers in a J2EE based n-tier model?

 

A     Client Tier

B     Web Tier

C     EJB Integration Tier

D     EIS Tier

E     EIS Integration Tier

F     Legacy Connectivity Tier

G     JCA Tier

 

Choices C, F and G are correct.

 

The question is asking what choices are not considered as J2EE tiers. There are no tiers called 'EJB Integration Tier', 'Legacy Connectivity Tier' or 'JCA Tier.' Hence choices C, F and G are correct.

J2EE applications have the following tiers: Client (Browsers, Applications, Applets, Mobile clients and so on), Web (presentation tier consisting of JSP as view and Servlets as controllers), EJB (Business Tier, consisting of EJB and supporting classes), EIS Integration (Java classes that integrate to the Enterprise Information System tier) and finally the EIS tier (relational databases, XML databases, ERP systems and so on.) Hence choices A, B, D and E are all valid J2EE application tiers and therefore incorrect.

 

 

 

 

 

215   Which of the following are true about client/server based applications?

 

A     Clients are typically used for data presentation, validation and for processing business logic.

B     Most client/server applications follow the Model2 architecture as opposed to n-tier applications that follow Model3.

C     In client/server applications, the client normally consists of the view, controller and parts of the model.

D     In typical client/server applications, the presentation tier (windows) generally talks to controller (a data dispatcher), which then talks to objects that represent the enterprise data.

E     Client/server applications generally have fat clients and sometimes, fat servers as well. Hence both the client and the server could offer portability problems.

 

Choices A, C and E are correct.

 

In 2-tier applications, clients are typically used for data presentation, validation of user inputs and processing of business logic. Hence choice A is correct.

If you compare the functions performed by the client with the MVC pattern, the client performs the duties of the view, the controller and parts of the model. The client interacts with the database and retrieves data. This data is then assembled into the required view. For example, a window that shows all orders taken in 1 day sorted by the customer number. The client thus acts as the view in MVC.

When some search criteria is entered and the user presses a button to retrieve necessary data, the client appropriately dispatches the request to the database interaction object that retrieves the necessary data. Here the client acts as the controller.

Most database interaction is encapsulated in a set of database access objects. These objects perform business rules processing. Here the client performs the job of the MVC model. Some logic is also encapsulated on the server side via triggers and stored procedures. Hence it is possible that the database also performs some model tasks in 2-tier applications. Hence choice C is correct.

Client/server applications frequently suffer from fat clients or fat servers or a combination of both. This is because either all the logic is coded in the client (4GL scripting language) or all the logic is coded on the server (through stored procedures and triggers) or a combination of both. This results in poor portability of such applications. Hence choice E is correct.

Choice B indicates that 2-tier applications follow Model2 architecture whereas n-tier applications follow Model3 architecture. This is untrue, because it is n-tier applications that normally follow the Model2 architecture. Hence choice B is incorrect.

Although object oriented client/server platforms may offer the tools to decouple windows and database interaction objects that is not a normal feature in 2-tier applications. Hence choice D is incorrect.

 

 

 

 

216   In n-tier models, which tier is best suited for implementing the view, and controller components of an MVC application?

 

A     Client Tier

B     Web Tier

C     MVC Tier

D     Business Tier

E     EIS Integration Tier

F     EIS Tier

 

Choice B is correct.

 

n-tier models typically follow a Model2 architecture where each tier has specific responsibilities. The view and most of the controller components are generally placed in the Web Tier (note: in some Model2 architectures, some controller components are also placed in the business logic tier.) Hence choice B is correct.

Choice A is incorrect because the client tier is not responsible for the view and controller objects. Choice C is incorrect because there no such tier as MVC tier. Choices D, E and F are incorrect because none of them hold the view components (although some controller components may be present in the Business logic tier.)

 

 

 

 

 

217   Which of the following are not service level requirements that affect software architecture?

 

A     Detailed Design

B     Performance

C     Reliability

D     Training

E     Availability

F     Security

G     Design Patterns

 

Choices A, D and G are correct.

 

Service level requirements (Cade 6) or Quality of Service (QoS) requirements are those that are needed by an application to satisfy the business requirements of a system. Performance, Scalability, Reliability, Availability, Extensibility, Maintainability, Manageability and Security are Non-functional service level requirements. While choices A and D illustrate important aspects of a software project, they are not considered QoS requirements. Although choice D describes a best practice that is frequently used by good designers, it too is not a Service level requirement. Hence choices A, D and G are correct.

Performance, Reliability, Availability and Security are service level requirements and therefore choices B, C, E and F are incorrect.

 

 

 

 

 

 

 

218   Which of the following UML diagrams may be best suited for a Business Analyst?

 

A     Deployment

B     Class

C     Use Case

D     Activity

E     Collaboration

F     Sequence

 

Choice C is correct.

 

Use Case diagrams (Cade 43)"show a set of use cases and actors and their relationships. Use Case diagrams show the static view of a system. These diagrams are especially important in organizing and modeling the behaviors of a system." Use case diagrams are frequently used by Business Analysts to capture business requirements of a system. Choice C is therefore correct.

Deployment diagrams (Cade 50)"show the configuration of run time processing nodes and the components that live within these nodes. Deployment diagrams address the static view of the architecture." Architects frequently use deployment diagrams. Choice A is therefore incorrect.

A class diagram (Cade 44)"shows a set of classes, interfaces and collaborations and their relationships…Class diagrams address the static design view of a system." Software designers frequently use class diagrams. Choice B is therefore incorrect.

Activity diagrams (Cade 48)"are a special kind of state chart diagram that show the flow from activity to activity within the system. This type of diagram is important in modeling the function of a system and emphasizing the flow of control among objects." Designers and Developers frequently use Activity diagrams. Hence choice D is incorrect.

A Collaboration diagram (Cade 46)"is an interaction diagram that emphasizes the structural organization of objects that send and receive messages." Designers and developers frequently use Interaction diagrams. Choice E is therefore incorrect.

Sequence Diagrams (Cade 46) are"interaction diagrams that emphasize the time ordering of messages." Interaction diagrams address the dynamic view of a system and are frequency used by designers and developers. Hence choice F is incorrect.

 

 

 

 

 

219   Since a dependency exists between two packages if a dependency exists between any two classes in the packages, it can be deduced that all package dependencies are transitive in nature. True/False?

 

A     True

B     False

 

Choice B is correct.

 

Package Diagrams (Fowler 108)"show packages of classes and the dependencies among them  A dependency exists between two elements if changes to the definition of one element may cause changes to the other…A dependency between two packages exists if any dependency exists between any two classes in the packages…With packages dependencies are non-transitive." The question makes an argument that all package dependencies are transitive in nature, which is false. Hence choice B is correct.

 

 

 

 

 

 

220            Refer to the exhibit for the following question.

 

 

 

In the diagram, the initialization call 1.1.1 is made by:

 

A     The Session Facade Object

B     The Acct Object

C     The AcctWebImpl Object

 

Choice C is correct.

 

The diagram shows a Collaboration Diagram (Collaboration diagrams are Interaction diagrams and they address the dynamic view of a system. They emphasize on the structural organization of objects. Read the SCEA for J2EE Study Guide for more information.)

1.1.1 Represents an initialization method called by the value object AcctWebImpl on itself upon construction.

 

 

 

 

221   Megasoft Corporation has a old application that uses a legacy database. Recently Megasoft made a decision to develop the front-end code for the application using the Java Applet technology. At this time however, Megasoft is not interested migrating its data to a relational database. In the order of importance, which of the following may be the best approach to connect to the legacy database.

 

A     JDBC-Bridge, Database Middleware, JDBC

B     Database Middleware, JDBC-ODBC bridge, JDBC

C     JDBC, Database Middleware, JDBC-ODBC bridge

D     JDBC, JDBC-ODBC Bridge, Database Middleware

Choice D is correct.

 

Updating the data storage tier (Jaworski 532.) "If the data storage tier of a legacy system utilizes a relational database system, JDBC may be used to provide connectivity to legacy databases. In most cases, legacy databases will not support a pure JDBC driver. If the existing system provides ODBC support, the JDBC-ODBC Bridge can be used. If the database uses custom drivers, it might be possible to find database middleware that supports the custom driver and either an ODBC or JDBC interface." It is therefore preferable to try for pure JDBC driver support, failing which one may opt for a JDBC-ODBC Bridge. If that too is not possible, then a database middleware may be used. Choice D is therefore correct.

Although choices A, B and C give the same three alternatives, they are in incorrect orders of preference. Hence choices A, B and C are incorrect.

 

 

 

 

 

 

222   Michael Fell runs a computer assembly company. He purchases parts from a wholesale parts distributor. Fell has a legacy application to track purchases of parts and sale of computers. Although the current system is very inflexible, the GUI is not very tightly coupled to the business layer. As an architect, what medium to long-term solution would you offer, given that Fell does not want to do away with his entire application yet?

 

A     Use Screen Scraping and Off-board server to provide information to a Java based application.

B     Refactor the legacy code to make it flexible.

C     Rewrite the inflexible parts of the application alone using Servlets

D     Decouple the existing front-end and replace it with a J2EE based solution

E     Replace the inflexible parts with a flexible ERP solution

 

Choice D is correct.

 

The key in this question is that the GUI is not very tightly coupled to the business layer. This means that the GUI can be decoupled form the system fairly easily. Further, the question asks for a medium to long-term solution. Thus in this case, using a J2EE based front-end may be preferable. Hence choice D is correct.

The use of screen scrapers may have been the best short-term solution. However it is certainly not the best medium to long-term approach. Hence choice A is incorrect.

Code re-factoring is not an alternative here. The question does not say anything about what the legacy system is written in and whether is easy to modularize its code. Hence choice B is incorrect.

The question only mentions about changing the GUI. They are not looking to rewrite all inflexible parts of the system.  Hence choice C is incorrect.

Choice E is incorrect because it refers to replacing all inflexible parts of the system. Further there is no indication anywhere in the question that an ERP solution might make it more flexible.

 

223   Which design pattern can be used to create a family of dependent objects?

 

A     Factory Method

B     Prototype

C     Builder

D     Abstract Factory

E     Singleton

 

Choice D is correct.

 

Abstract Factory (GOF 87)"Provide an interface for creating families of related or dependent objects without specifying their concrete classes." Hence choice D 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." Hence choice A 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 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.

Singleton (GOF 127)" Ensure a class only has one instance, and provide a global point of access to it." Hence choice E is incorrect.

 

 

 

 

224   Pensacola, a Florida based soda company has just started operations in Dallas, TX to counter competition from Dr. Pepper. Pensacola believes that using a J2EE based application will put them ahead of the competition. Their new architect is suggesting that Session Beans be used to provide a unified interface to the Entity Beans in the system. The use of session beans here illustrates the use of what design pattern?

 

A     Flyweight

B     Proxy

C     Faade

D     Decorator

E     Adapter

F     Bridge

 

Choice C is correct.

 

Fa ade (GOF 185)"Provide a unified interface to a set of interfaces in a subsystem."

The following is taken from:

http://java.sun.com/blueprints/corej2eepatterns/Patterns/SessionFacade.html

"Use a session bean as a facade to encapsulate the complexity of interactions between the business objects participating in a workflow. The Session Facade manages the business objects, and provides a uniform coarse-grained service access layer to clients." Hence choice C is correct.

Flyweight (GOF 195)"Use sharing to support large numbers of fine-grained object efficiently." Hence choice A is incorrect.

Proxy (GOF 207)"Provide a surrogate or placeholder for another object to control access to it." Hence choice B is incorrect.

Decorator (GOF 175)"Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality." Hence choice D is incorrect.

Adapter (GOF 139)"Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces." Hence choice E is incorrect.

Bridge (GOF 151)"Decouple an abstraction from its implementation so that the two can vary independently." Hence choice F is incorrect.

 

 

 

 

 

225   One of the advantages of using Stateless Session Beans is that they are lightweight objects and do not have conversational state overheads. Further, the container swaps these bean instances in and out of the bean pool to appropriately manage resources. This allows the container to use fewer instances of the bean to service a larger number of clients. What design pattern is being illustrated here?

 

A     Decorator

B     Factory

C     Faade

D     Flyweight

E     Visitor

 

Choice D is correct.

 

Flyweight (GOF 195)"Use sharing to support large numbers of fine-grained object efficiently." Here the container uses fewer instances of Stateless Session Beans to service a larger number of clients. Hence choice D is correct.

Decorator (GOF 175)"Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality." Hence choice A is incorrect.

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 B is incorrect.

Facade (GOF 185)"Provide a unified interface to a set of interfaces in a subsystem." Hence choice C 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." Hence choice E is incorrect.


javabeat | advertise | about us | contact | useful resources
Copyright (2004 - 2013), JavaBeat