OCMJEA Mock Exam – 8

177 . You are designing a 3-tier architecture for a new application your company intends to deploy as part of it’s marketing strategy. This application will allow users to book rental cars over the web and is estimated to save the company millions over the next few years. Due to the sheer number of users, you have decided to use the Front Controller pattern?
Which of the following statements describe the Front Controller pattern?

Choose the one below:

  1. The Front Controller pattern is primarily used as a cheap alternative to a CISCO router. It is used as a software alternative to a hardware load balancer
  2. Provides a central point of entry
  3. Provides a central point of entry for load balancing
  4. The controller manages client requests, security, delegation of business processing, error handling, view selection and content creation strategies
  5. The controller manages the client’s request including delegating business processing, error handling, view selection and content creation strategies. But is does not have anything to do with security
  6. The Front Controller is just another way of describing the Controller out of the Model View Controller architecture
  7. The Front Controller is just using the Controller out of the Model View Controller architecture for load balancing

178 . You are designing a complex set of classes that provides a secure framework for other programmers to use. The idea behind this framework is that it will allow other programmers to write secure programs without getting bogged down with the complexities of writing secure applications?
What sort of design pattern is being used here?

Choose the one below:

  1. Composite
  2. Faade
  3. Decorator
  4. Adapter
  5. Mediator

179 . What is the difference between the abstract factory pattern and the factory method pattern?

  1. The factory method makes objects that should be used together. This is not the case for the abstract factory
  2. The abstract factory pattern provides an interface for creating a family of objects whereas factory method provides an interface for creating one object
  3. In the abstract factory pattern the objects that the factory makes are to be used together. This is not necessarily true in the factory method pattern
  4. The factory method pattern is used when the class does not know the class of the object it must create. But in the abstract factory this is known in advance
  5. The factory method and abstract factory are essentially the same pattern but two different names are used to describe them depending on the circumstances when they are implemented

180 . You’re designing a paint application and as part of the user interface you have a toolbar along the left hand side of the screen. Each of the icons on the toolbar has different actions when you are using different tools. The way you’ve structured it, the application is required to pass commands from one object to another. When the appropriate object receives the command, it handles the request. This is an example of which pattern?

Choose the one below:

  1. Command
  2. Chain of Responsibility
  3. Adapter
  4. Interpreter
  5. Strategy

181 . You’ve had enough of you existing IDE (Integrated Development Environment) and have started work on designing your own. At the moment you’re working on the undo part of the application, basically you need to be able to roll an object back so its previous state?
What pattern would you use to do this?

Choose the one below:

  1. Memento
  2. State
  3. Mediator
  4. Rollback
  5. Transaction
  6. ACID

182. What is true about this diagram?

Choose the one below:

  1. Object 1 calls the method call1() on Object 2
  2. Object 2 executes its own method call3(). This method in turn creates Object 3
  3. Object 1 executes its own method call1(). This method in turn creates Object 2
  4. Object 2 calls the method call3() on Object 3

183 . What are the benefits of asynchronous messaging?

  1. Less coupling between the sender and receiver
  2. Provides an instant response
  3. Does not block the sender
  4. Good for transaction processing
  5. You can’t get an instant response
  6. Network doesn’t have to be available

184 . You are designing an online shopping application to make it easier for customers to order products from your company. The aim is that the majority of customers buying over the phone will start using the web instead. When customers purchases goods online they will use credit cards and will require an instant response as to whether the sale has been approved or not?
What type of messaging should be used? (Note: The credit card validation is carried out by another very powerful system)

Choose the one below:

  1. Synchronous messaging
  2. Asynchronous messaging
  3. You shouldn’t be using messaging at all as it’s not transactional
  4. You could use messaging because it is transactional however it’s not advised, as the system would never perform well enough for an instant response

185 . What should be used if you don’t need an instant response from a message?

  1. Synchronous messaging
  2. Asynchronous messaging

186 . You overheard two colleagues arguing about the difference between Localization and Internationalization. They turn to you to ask you to settle the argument?
What is the difference between Localization and Internationalization?

Choose the one below:

  1. Internationalization is the process of preparing a program to be used in a country other than England
  2. Internationalization is the process of preparing a program to be used in any country
  3. Localization is the process of preparing a program to be used in a country other than England
  4. Localization is the process of preparing a program to be used in any country

187 . You have an existing mail order application that runs as an applet on the customer’s browser. The applet connects to your server to retrieve product information.What would you expect to change to meet the needs of users in different countries? (Note: all data is sent securely over SSL)

Choose the one below:

  1. GUI text, e.g. Message box text etc
  2. Security login procedures
  3. Dates
  4. Numbers, e.g. Currency
  5. The way the program writes to binary files
  6. Icons, Images
  7. The way the program writes to text files

188 . Your company has a custom operating system that it developed for some robotics hardware to be used in their research departments. One of the researchers has written a cut down Virtual Machine to run on this OS. You have started to develop some software to run on this VM however you need to convert the Unicode to 8 bit characters. In order to do this you will need to use?

Choose the one below:

  1. FileWriter
  2. OutputStreamWriter
  3. BufferedWriter
  4. StreamWriter

189 . You need to convert 8 bit text to Unicode. To do this you use?

  1. FileReader
  2. InputStreamReader
  3. BufferedReader
  4. StreamReader

190 . What is the difference between composite aggregation and normal aggregation?

  1. Aggregation defines a part of relationship but both objects can exist independently. But with composite aggregation if one part is removed then the other part will be removed. Think of a plane the wings have a composite aggregation relationship with the body of the plane
  2. Composite Aggregation defines a part of relationship but both objects can exist independently. But with aggregation if one part is removed then the other part will be removed. Think of a plane, the wings have an aggregation relationship with the body of the plane

191 . You are looking at a class diagram that another developer has drawn. You notice a solid black diamond and a line linking two classes together. What does the black diamond imply in UML?

  1. Aggregation
  2. Association
  3. Composite Aggregation / Composition
  4. Dependency
  5. Inheritance/Generalization

192 . What does a triangular arrow shape with a solid line mean in UML? (Note: The triangle is an outline, and not solid)

Choose the one below:

  1. Aggregation
  2. Association
  3. Composite Aggregation / Composition
  4. Dependency
  5. Inheritance/Generalization

193 . You are studying a class diagram of an exiting system so that the new functionality you are adding uses the existing class attributes wherever possible. What do the following symbols mean in UML with regards to visibility?

Choose the one below:

  1. # public, + protected, – private
  2. + public, – protected, # private
  3. + public, # protected, – private
  4. # public, – protected, + private

194 . Which of the following are true about Vertical Scalability?

  1. Achieved by adding servers to the system
  2. Achieved by adding capacity (memory, CPU and so on)
  3. It is generally more expensive than Horizontal scaling
  4. Decreases manageability
  5. Requires few or no changes to the system architecture
  6. Not supported by J2EE
  7. Has little or no impact on the reliability and availability of the system

195 . Which of the following are not true about 2-tier architecture models?

  1. Clients may be validation intensive, consequently requiring powerful hardware
  2. Any change to one tier typically affects both tiers
  3. Represents a single point of failure
  4. Each client makes a direct connection with the server
  5. They are not very maintainable
  6. They are quite manageable

196 . Refer to the following diagram?

Choose the one below:

  1. Class A inherits from Class B
  2. Class B inherits from Class A
  3. Class B has a dependency to Class A
  4. Class A has an aggregation to Class B

197 . In a UML class diagram Private, Protected and Public attributes are shown by?

Choose the one below:

  1. -, +,#
  2. +, -,hash
  3. #, -, +
  4. -,#, +
  5. +,#, -
  6. #, +, -

198 . Which of the following may be used for synchronously communicating with legacy systems?

  1. IIOP
  2. HTTP
  3. SHTML
  4. JRMP with JNI
  5. SMTP
  6. RMI / IIOP
  7. MOM

199 . What is an off-board server used for?

  1. Providing Single-Sign on to a Java based application
  2. Delegating complex processing to a separate server
  3. Enable secure remote access to a mainframe by forwarding SSL requests to serial connections
  4. As a database for storing the public keys of valid Certification Authorities (CA)
  5. For performing symmetric key cryptography

200 . Company ABC has a predominantly EJB based J2EE application that has be accessed by CORBA clients. Which connectivity option would you recommend?

Choose the one below:

  1. A RMI-JRMP
  2. B RMI with JNI
  3. C Java IDL
  4. D RMI-IIOP
  5. E HTTP tunneling

201 . Which of the Classes and Interfaces need to be created by a bean developer?

  1. Home Interface
  2. Distributed Interface
  3. Remote Interface
  4. Bean Class
  5. Bean Interface

Answers

177 : 2 & 4 is correct.
Explanation:
The following is taken from Core J2EE Patterns: Best Practices and Design Strategies page 369″Use a controller as the initial point of contact for handling a request. The controller manages the handling of the request, including invoking security services such as authentication and authorization, delegating business processing, managing the choice of an appropriate view, handling errors, and managing the selection of content creation strategies. The main aim of the Front Controller pattern is to centralize view management. For example if a web page is moved all the links to it would need to be updated by using this pattern you can pass all requests through the Front Controller only needing to make changes in one place. The Front Controller is classified by Sun as a Presentation Tier pattern. Choices 1 and 2 are incorrect because the Front Controller has nothing to do with load balancing. Choice 5 is incorrect as the Front Controller can invoke security services and choices 6 and 7 are incorrect because the Front Controller does not represent the Controller out of the MVC architecture.

Some useful links:

http://developer.java.sun.com/developer/technicalArticles/J2EE/patterns/

http://java.sun.com/blueprints/patterns/j2ee_patterns/front_controller/index.html

http://java.sun.com/blueprints/

Useful book:

Core J2EE Patterns: Best Practices and Design Strategies – ISBN: 0130648841A sample chapter is available here: http://www.sun.com/books/catalog/crupi/index_Table+of+Contents.html

Note: This type of question will probably feature in the new EJB 2.0 specification version of the SCEA certification.

178 : 2 is correct.
Explanation:
Facade – (GOF 185): “Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. “The other patterns are described below:

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. “Composite – (GOF 163):”Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. “Decorator – (GOF 175):”Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to sub classing for extending functionality. “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 it lets you vary their interaction independently.”

179 : 2 is correct.
Explanation:
Both the Abstract Factory and Factory Method are Creational patterns. Abstract Factory – (GOF 87): “Provide an interface for creating families of related or dependent objects without specifying their concrete classes. “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. “Choice 1 offers a description of the abstract factory pattern not the factory method. The descriptions in choices 3 and 4 are the wrong way round. Choice 5 is incorrect as the two patterns are different.

180 : 2 is correct.
Explanation:
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. “Below are descriptions of the other patterns: 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 “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. “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. “Strategy – (GOF 315):”Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.”

181 : 1 is correct.
Explanation:
Memento – (GOF 283):”Without violating encapsulation, capture and externalise an object’s internal state so that the object can be restored to this state later. “Choices 4, 5 and 6 are not names of patterns. Rollback is something you would do if a transaction were terminated halfway through. Transaction is self-explanatory. ACID stands for Atomic, Consistent, Isolatable and Durable. All transactions must adhere to this. Below are descriptions of the other patterns: State – (GOF 305):”Allow an object to alter its behavior when its internal state changes. The object will appear to change its class. “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 it lets you vary their interaction independently.”

182 : 1 & 4 is correct.
Explanation:
The diagram shows a UML sequence diagram. This type of diagram shows the interaction of different objects. Time is shown from the top of the page descending. The white rectangles on the dotted lines show the objects life. Method calls are made from one object to another. In this diagram Object 1 calls Object 2’s method call1(). Where the arrow begins, the object represents the caller, and where it ends, the object called. The text above the arrow is the name of the method.For more information about UML:http://www.uml.org/

183 : 1,3 & 6 is correct.
Explanation:
The main difference between asynchronous messaging and synchronous messaging is that synchronous provides an instant response. This means that when using asynchronous messaging, clients do not have not wait for responses; they send messages and then carry on with what they were doing. This reduces the coupling between the sender and receiver and it also means that the network doesn’t have to be available. Choices 2 and 4 are incorrect because they describe synchronous messaging. Although choice 5 is correct it is not a benefit of synchronous messaging.

184 : 1 is correct.
Explanation:
Synchronous messaging provides an instant response and is therefore the right answer. It is always arguable as to whether messaging should be used if you require an instant response but if you do decide to use messaging then you should always use synchronous messaging when needing an instant response. Choice 2 is incorrect because asynchronous messaging does not provide an instant response. You can make messaging transactional by creating your own transactions in your code. Hence choice 3 is incorrect. Choice 4 is arguable too, but it is not the most appropriate answer because the question suggests that the system the messages will be sent to is very powerful and will be able to cope with the volume of traffic. So choice 4 would be incorrect as it suggests that the system will not perform well enough for an instant response.

185 : 2 is correct.
Explanation:
Synchronous messaging provides an instant response therefore asynchronous messaging is correct. Synchronous, tightly coupled communication between distributed components: This is the model of CORBA, RMI, EJB and so on. The programming model is called Remote Procedure Call (RPC).Asynchronous, loosely coupled communication between components: This is the Message Oriented Middleware or MOM model. The programming model is called Messaging.

186 : 2 is correct.
Explanation:
Internationalization: Adapting a program for use in any country is called Internationalization. Localization: The process of adapting a program for use in a particular country is referred to as Localization. During Localization the language of the text, message icons, colors used, dialogs, number formats, time representation and even sorting algorithms are subject to change. Choice 1 is incorrect because it is the other way around. Choices 3 and 4 are not accurate descriptions of Localization.

187 : 1,3,4,6 & 7 is correct.
Explanation:
List of items that may be subject to Internationalization:

Language for Messages

Formats – Numeric, Date and so on

Dictionary sort order

Currency symbol and position

Tax and other legal rules

Cultural preferences

You would not need to change the way you wrote to binary files but you may need to change the way you write to text files because of the Unicode to 8 bit differences.

188 : 2 is correct.
Explanation:
The OutputStreamWriter can be used to convert Unicode into 8 bit characters. Normally this is used in Internationalization to convert Unicode into local character encoding but it would work well in this situation. Choices 1, 3 and 4 serve different purposes in the java.io package. Java support for Internationalization Properties Locale Resource Bundle Unicode Java.text Package InputStreamReader OutputStreamWriter

189 : 2 is correct.
Explanation:
The InputStreamReader can be used to convert 8 bit characters to Unicode. Choices 1, 3 and 4 serve different purposes in the java.io package.Java support for Internationalization:· Properties· Locale· Resource Bundle· Unicode· Java.text Package· InputStreamReader· OutputStreamWriter

190 : 1 is correct.
Explanation:
As the answer states aggregation defines a part of relationship but both objects can exist independently. But with composite aggregation if one part is removed then the other part will be removed. The following is taken from: http://www.moskalyuk.com/edu/uml/interview_questions.htm Composition is a stronger form of aggregation. The object which is “contained” in another object is expected to live and die with the object which “contains” it. Composition is represented in the UML by a darkened diamond. An example of a composite relation is a Book and Chapter. A Book “has a” Chapter, and the Chapter cannot exist without the Book. For more information about UML please go to: http://www.uml.org/

191 : 4 is correct.
Explanation:
Composite Aggregation / Composition is shown by a solid black diamond. Aggregation defines a part of relationship but both objects can exist independently. But with composite aggregation if one part is removed then the other part will be removed. Think of a plane the wings have a composite aggregation relationship with the body of the plane. Note: Inheritance and Generalization are used to describe the same thing. The same is also true about Composite Aggregation and Composition. Aggregation is shown as a white diamond (the diamond shape is a black outline with the centre white). Association is just a single line linking classes/objects; this can have multiplicity and direction. The following is taken from:http://www.moskalyuk.com/edu/uml/interview_questions.htm Composition is a stronger form of aggregation. The object which is “contained” in another object is expected to live and die with the object which “contains” it. Composition is represented in the UML by a darkened diamond. An example of a composite relation is a Book and Chapter. A Book “has a” Chapter, and the Chapter cannot exist without the Book. For more information about UML:http://www.uml.org/

192 : 5 is correct.
Explanation:
In UML Inheritance/Generalization is shown with a triangular arrow shape. So whenever you extend a class, you are inheriting from the class you are extending. Note: Inheritance and Generalization are used to describe the same thing. The same is also true about Composite Aggregation and Composition. Aggregation is shown a white diamond (the diamond shape is a black outline with the centre white). Association is just a single line linking classes/objects; this can have multiplicity and direction. Composite Aggregation / Composition is shown by a solid black diamond. For more information about UML:http://www.uml.org/

193 : 3 is correct.
Explanation:
As the answer states the + # – symbols represent the following levels of visibility.+ Public# Protected- Private For more information about UML please go to:http://www.uml.org/

194 : 2,5 & 7 is correct.
Explanation:
Vertical Scalability, by definition means increasing a system’s capacity by adding memory, processors and so on. Of the two types of Scalability (Vertical and Horizontal), Vertical Scalability is the easier to achieve because it involves few changes to the existing system’s architecture. Also adding more CPU or memory to an existing system does not have any impact on reliability or availability because if the system or component fails, in the absence of redundant systems, availability and reliability would suffer. Hence choices 2, 5 and 7 are correct.

Choice 1 is incorrect because it actually describes Horizontal Scalability, which is achieved by adding more servers to a system. Horizontal Scalability is tougher to achieve because the architecture should inherently support a multi-server environment. However once implemented, it has a positive impact on the system’s reliability and availability because it provides fault tolerance capabilities.

Choice 3 is incorrect because generally it is cheaper to add capacity than to add entire new systems. Choice 4 is incorrect because adding capacity should have no impact on the manageability of a system. Choice 6 is incorrect because Vertical Scalability is easy to achieve. Most J2EE vendors also provide support for the more difficult Horizontal Scalability.

195 : 2,3 & 6 is correct.
Explanation:
The question asks for points about 2-tier client/server systems that are not true. Choice 2 is untrue because a change to one tier need not necessarily affect the other tier. For example consider an Order Entry system where the users need to see transaction history for individual customers. A new screen can be developed to take data from the transaction tables and display it on the client. In this example, no changes are required on the server. Consider an alternate example where a stored procedure accessing data spread in multiple tables now queries a materialized view. No changes would be required to clients that call the stored procedure, as long as all input and output remains the same.

Although it may be true in many cases, Client/Server architectures do not always represent single points of failure. With single database servers, of course if the server fails, clients may not be able to connect to the database. However in multi-database applications, if parts of the client or server fail, other parts of the system may still be accessible. Hence choice 3 is a right answer.

2-tier architectures are not very manageable. Although the servers can be managed centrally, client PCs are always distributed at user locations and it is very difficult to troubleshoot them without local staff. Hence choice 6 is a right answer.

Choice 1 correctly reflects what happens on a client in 2-tier applications. Choice 4 explains how clients interact with the database and choice 5 clearly lists that 2-tier architectures are not easily maintainable because of constant software updates required on the clients. Hence they are all incorrect answers.

196 : 2 is correct.
Explanation:
From the diagram it can be inferred that A and B are concrete classes and B extends A. This is shown by the generalization relationship between B and A. Hence choice 2 is correct.

Choice 1 is incorrect because class A does not inherit from class B. Choice 3 is incorrect because the relationship between the classes A and B is generalization, not dependency. Finally choice 4 is incorrect because A has an aggregation relationship with Interface C, not class B.

197 : 4 is correct.
Explanation:
In UML notation, access modifiers are shown by the signs -, # and + to represent Private, Protected and Public. Hence choice 4 is correct. All other choices show incorrect combinations.

198 : 1,4 & 6 is correct.
Explanation:
IIOP (Internet Inter Operable Protocol) is the protocol used by CORBA. JRMP (Java Remote Method Protocol) is the protocol used by Java-RMI. RMI / IIOP is EJB1.1’s protocol. All three of these methods are examples of RPC (Remote Procedure calls) based communication, which is inherently synchronous in nature. Note that there are exceptions (event handling in CORBA and Message Driven Beans in EJB2.0), but generally speaking RPC is used for synchronous communication. Hence 1, 4 and 6 are correct.

HTTP, SHTML and SMTP are unrelated jargons, used for confusing the reader. Message Oriented Middleware (MOM) is used for asynchronous messaging. Hence choices 2, 3, 5 and 7 are incorrect.

199 : 3 is correct.
Explanation:
An off-board server is used enable secure remote access to mainframes. This is done typically done by forwarding SSL requests to the mainframes via serial connections, as indicated by choice 3.

An off-board server does not provide single sign on capabilities to a J2EE application. It is also not an application server that can take up complex business logic processing. An Off board server does not store public keys of trusted Certification Authorities (CA) or perform symmetric key encryption. Hence choices 1, 2, 4 and 5 are all incorrect.

200 : 4 is correct.
Explanation:
RMI-IIOP stands for Remote Method Invocation (using IIOP as the transport.) This is the protocol supported by EJB1.1 Hence choice 4 is correct.

RMI-JRMP is used only when dealing with native Java clients. The question talks about CORBA clients but does not say anything about pure Java clients. Hence choice 1 is incorrect. There is also no mention of JNI support. Hence choice 2 is incorrect. Java IDL is useful when you have a predominantly CORBA based application. Hence choice 3 is incorrect. HTTP tunneling is a way to allow protocols to masquerading as other protocols and bypass firewall restrictions. Hence choice 5 is incorrect.

201 : 1,3 & 4 is correct.
Explanation:
When developing EJB applications, developers need to create the Home Interface, the Remote Interface and the Bean Class. Hence choices 1, 3 and 4 are correct.

There is no such thing as the Distributed Interface or the Bean Interface. Hence choices 2 and 5 are incorrect.

Comments

comments

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.

Speak Your Mind

*