OCMJEA Mock Exam – 7

152 . You have just started a new job working for a top finance company and you have been asked to provide a user-friendly interface to an existing mainframe application. You don’t have any access to the mainframes source code. What is the best technique for this?

Choose the one below:

  1. It can’t be done
  2. Use a screen scraper
  3. Re-write the main frame using Java and high-end Unix servers. Although it may take some time to do this in the long run this will benefit the company
  4. Write a Java front end then use CORBA to communicate with the mainframe
  5. Use the Java Native Interface (JNI) to communicate with the mainframe
  6. Use object Mapping
  7. Use JMS

153 . You are working for a company that has yet to realise the full potential of Java. You offer to show them some of the great things Java can do by integrating a new application with an existing CORBA system. Your bosses will then assess the performance and reliability of this new system?
How will you connect your RMI application to the CORBA system?

Choose the one below:

  1. Use Java-IDL
  2. This is a standard feature of RMI
  3. Can’t be done
  4. Can only be done by using JNI
  5. Use RMI-IIOP

154 . You are working for a car leasing company and you need to integrate with one of their mainframe applications. You should do this using either object mapping or screen scraping?
When should you use object mapping?

Choose the one below:

  1. You should always use screen scrapers when you have the option
  2. When you have access to the mainframes code
  3. When you don’t have access to the mainframes code
  4. When you are short of time and need a quick solution

155 . You have just joined a new company and have spent some time chatting with the network administrator. He has mentioned that one of the servers is an off-board server?
What is an off-board server?

Choose the one below:

  1. Another way to describe a standard proxy server
  2. Another type of a screen-scraping program, (Like an object mapping one)
  3. A server that runs within the DMZ
  4. A proxy for a legacy system

156 . You are designing an online cinema ticket booking application. At the moment you plan to have a controller to maintain user sessions, a customer component to hold personal details, a credit card validation component, a set of GUI screens and a cinema component with details of all movies and seating capacities?
What should be used for each component?

Choose the one below:

  1. The controller should be a Stateful Session bean. The customer should be a Stateful Session bean. The cinema component should be a Stateful Session bean. The credit card validation component should be an Entity bean
  2. The controller should be a Servlet. The customer should be a Stateful Session bean. The cinema component should be a Stateful Session bean. The credit card validation component should be an Entity bean
  3. The controller should be a Stateful Session bean. The customer should be a Servlet. The cinema component should be a Stateful Session bean. The credit card validation component should be a Stateful Session bean
  4. The controller should be a Servlet. The customer should be a Servlet. The cinema component should be a Stateful Session bean. The credit card validation component should be a Stateful Session bean
  5. The controller should be a Stateful Session bean. The customer should be an Entity bean. The cinema component should be an Entity bean. The credit card validation component should be a Stateless Session bean
  6. The controller should be a Servlet. The cinema component should be a Stateful Session bean. The cinema component should be an Entity bean. The credit card validation component should be a Stateless Session bean
  7. The controller should be a Stateful Session bean. The customer should be an Entity bean. The cinema component should be an Entity bean. The credit card validation component should be a Stateless Session bean
  8. The controller should be a Servlet. The customer should be an Entity bean. The cinema component should be an Entity bean. The credit card validation component should be a Stateless Session bean
  9. Make the GUI using JSP pages
  10. Make the GUI an applet

157 . You have an Enterprise Bean that represents a customer’s account. One of the methods that this bean provides is deductCost(float amount) This method is used when a customer buys something from your company’s website. This method must be executed as part of an existing transaction?
What is the correct attribute setting in the deployment descriptor?

Choose the one below:

  1. REQUIRED
  2. REQUIRES NEW
  3. SUPPORTS
  4. MANDATORY

158 . You have a method that can’t be executed in a transaction. What is the correct attribute in the deployment descriptor?

  1. Leave it empty this is the default
  2. NEVER
  3. NOT SUPPORTED
  4. NO_TRANSACTIONS

159 . You have been reading up of the Gang of Four patterns and you notice that the Home interface of an Enterprise Javabean is actually based on one of the patterns?
Which pattern is the Home Interface of an Enterprise Javabean based on?

Choose the one below:

  1. Singleton
  2. Facade
  3. Builder
  4. Factory Method

160 . You’ve been developing a chat application so that members of your team can keep in touch with each other irrespective of their location. You decided to implement the application as a Java Applet. In order to make sure the user has the latest version, you require the applet to connect back to the server it was downloaded from and check with a file there. Can this be done with JDK 1.3 or 1.4 without modifying the browser’s policy files?

True/False?

Choose the one below:

  1. True
  2. False

161 . You are writing an Enterprise Javabean to represent a Flight in a Travel agency application. One of the developers recommended that you use Bean Managed Persistence (BMP) for the EJB?
What is true about BMP?

Choose the one below:

  1. Improves your ability to move your EJB from one Application server to another
  2. Reduces your ability to move your EJB from one Application server to another
  3. Improves your ability to move your EJB from one data store to another
  4. Reduces your ability to move your EJB from one data store to another

162 . What do Atomic and Consistent mean in reference to ACID?

  1. Atomic means a transaction must execute completely or not at all
  2. Atomic means a transaction must execute completely or log where it was stopped
  3. Consistent means a transaction must execute completely or log where it was stopped
  4. Atomic means the transaction is the same as other transactions in structure
  5. Consistent means the transaction is the same as other transactions in structure
  6. Consistent means the transaction was started and finished within the specified time
  7. Consistent means that the integrity of the underlying data source is always maintained

163 . You are working late at the office one day when the security guard informs that you have to leave as the building is closed for the evening. As you are working on a big project you decide to continue your work at home. However when you try to connect to the application from home you get no response. You are trying to connect to your RMI-JRMP application; the port is available on the firewall, what is the most likely reason why you can’t connect?

Choose the one below:

  1. The port on the firewall isn’t really available
  2. The company’s proxy servers are filtering out your request based upon your IP address
  3. You have typed the connection address incorrectly
  4. Your application is only listening for internal requests and you will need to change setting in the security.policy file if you wish to connect from home
  5. Your company knows that most hacking takes place at night and takes all of its systems off-line during the night

164 . How are Entity Beans persisted?

  1. Entity beans are stored in memory by the Application server
  2. Entity beans are not persisted
  3. They are serialized and stored on a database
  4. They are NOT serialized but rather stored in a persistent storage medium such as a database
  5. It is up to the developer, than can either be serialized or mapped directly

165 . Which of the following statements are true? (Note: This question assumes that the no-args constructor and setEntityContext() method have already been called)

Choose the one below:

  1. Entity Beans start in the”ready” state and move into the”pooled” state only after ejbActivate() has been called on them
  2. Entity Beans start in the”pooled” state and move into the”ready” state only after ejbActivate() has been called on them
  3. Entity Beans aren’t pooled
  4. Entity Beans are never in either state

166 . How do you find a particular Entity Bean?

  1. Call various find methods defined in the Home interface
  2. Call various find methods defined in the Remote interface

167 . Which statements are true?

  1. ejbFind() returns the Primary Key
  2. The find method/s in the Home interface return an EJBObject or an Enumeration
  3. The find method/s in the Home interface return a Primary Key
  4. ejbFind() returns an EJBObject
  5. The find method/s in the Remote interface return an EJBObject
  6. The find method/s in the Remote interface return a Primary Key

168 . You are at home trying to work on an application you’re developing for your company. You want to log on to your machine at work and develop code for your application however you are having some trouble connecting directly to the application (running on port 1099)?
What is the most likely reason that you can’t connect?

Choose the one below:

  1. A typing error in the connection details
  2. Your company is filtering traffic based upon IP address
  3. Traffic is being filtered based upon the port number requested
  4. You need to update the security manager that is being used with the application to allow external connections
  5. There is a bug in your program stopping anyone from connecting whether internal or external

169 . You know that Java allows you to run JRMP over HTTP, to tunnel through firewalls but does Java allow you to run CORBA over HTTP?

True/False?

Choose the one below:

  1. True
  2. False

170 . You are working for an investment bank. You have written an applet to display the current price of the shares that traders have selected for monitoring. For the applet to work, it needs to authenticate who the client is. It does this by reading a file held locally on the client’s machine. You know that applets can’t read files stored on a local machine by default. So you have placed the applet in a jar file and that is code signed by a trusted certificate authority?
Is signing the code enough for the applet to be able to read the local file? (Note: This is based on JDK 1.3 and 1.4)

Choose the one below:

  1. Yes it would work fine without limitation as the code is signed
  2. No the security manager of the browser would prohibit this
  3. The applet would have been able to read the file already under JDK 1.3 and 1.4
  4. As long as the code is signed is doesn’t matter which certificate authority signed it
  5. It may or may not work depending on the browser’s security policy

171 . You are developing an application to be used at a major bank. Security is a crucial element and you have decided to use JAAS. The GUI will be based on the MVC framework and it uses swing. The application will connect people in the same office so that they can all securely review the same financial data?
What protocol should you use to do this?

Choose the one below:

  1. IIOP
  2. JRMP
  3. HTTP
  4. HTTPS

172 . What are the benefits of using the Service Locator pattern?

  1. It is used primary by Servlets to locate other services such as JMS. A good example of this pattern would be a web based login facility. If a client enters an incorrect password their need to be redirected to a different but their session needs to be maintained across the application
  2. It is used to catalog Enterprise Beans so that other beans can find them quickly and efficiently. For example if you need to forward request from a Session Bean to an Entity Bean then the Session Bean requests the location of the Entity Bean from the Service Locator object. The Service Locator looks in a table (like a HashMap) and returns the Entity Beans location
  3. The Service Locator pattern can improve performance by introducing a caching facility
  4. There is a slight loss of performance when using the Service Locator pattern but this is out weighed by the improved maintainability of the code
  5. None of the definitions of the Service Locator pattern are accurate
  6. The Service Locator pattern is used to hide the complexities of initial object creation, EJB lookups and object re-creation
  7. Multiple clients can reuse the same Service Locator pattern

173 . When would you use Tunnelling?

  1. When you don’t have access to any spare ports of the Firewall and need to tunnel your application through an existing port
  2. To break out of prison
  3. When you do have access to spare ports of the Firewall and are able to use them. So you tunnel your application out of one of these new ports that was created just for your application
  4. When you are using IIOP with RMI

174 . You are working for a small to medium sized business that has just started to use servers to host J2EE Applications (its own and clients’.) However since its launch into this new area there have been three separate instances of hacks involving access of sensitive sales information. A security consultant has been brought in to assess the situation and he recommends that your company use a DMZ. What is a DMZ?

  1. The network behind a firewall that’s protected from the Internet
  2. The region inside the inner firewall (we are assuming that there are two firewalls). This network is called the DMZ
  3. The network outside of the outer firewall. This could be the Internet or other client networks. (We are assuming that there are two firewalls)
  4. A region between two firewalls. The Internet would come in through the first firewall but only systems within the first firewall in the DMZ can go through the second firewall

175 . You are designing a web-based application for an online recipe site. Although this may not seem that popular, the estimated number of unique visitors to the site is 100000 per day. The site is purely informational, you can’t buy recipes or upload your own (if you wish to add your own recipes they have to be emailed to the webmaster). Despite that fact that there no transaction and persistence requirement it is still recommended that you use an Application server and Enterprise beans. The main reason for using the Application server and Enterprise Beans is that it allows you to remove some of the processing from the web servers and this increases the performance of the site?

True/False?

Choose the one below:

  1. True
  2. False

176 . You are an enterprise consultant for one of the Fortune 500 companies. You have been discussing a possible design for a 3-tier application with a prospective client. They know very little about Java and are asking you if Java is always the best solution. Your response is that although normally for each project many factors have to be considered before selecting the programming language and framework, because this is a 3-tier architecture Java is definitely the best solution?

True/False?

Choose the one below:

  1. True
  2. False

Answers

152 : 2 is correct.
Explanation:
The key to this question is that you don’t have access to the mainframes source code. A screen scraper emulates a mainframe terminal. Basically the screen scraper logs on to the mainframe like a normal user and sends requests to the mainframe and then reads the response. The problem with a screen scraper is that if you change any of the mainframes code there is always the possibility that the screen scraper will stop working.Choice 1 is incorrect because it is possible to add a GUI to the system. Choice 3 would take far too long, cost too much and is not what the customer wants. Choices 4, 5 and 6 would all require access to the mainframes source code. Choice 7 is incorrect because there is no mention that the mainframe supports a messaging system. Some of them do and even provide interfaces for JMS however as it is not stated in the question it is not the right answer.

153 : 1 is correct.
Explanation:
The following is taken from:http://java.sun.com/j2se/1.3/docs/guide/idl/jidlFAQ.htmThere are several scenarios that will define how you will want to create distributed CORBA applications. Here are some of them: Java IDL – If you have been developing CORBA applications using IDL for some time, you will probably want to stay in this environment. Create the interfaces using IDL, and define the client and server applications using the Java programming language to take advantage of its “Write Once, Run Anywhere TM” portability, its highly productive implementation environment, and its very robust platform. RMI-JRMP – If all of your applications are written in the Java programming language, you will probably want to use Java RMI to enable communication between Java objects on different virtual machines and different physical machines. Using Java RMI without its IIOP option leverages its strengths of code portability, security, and garbage collection. RMI-IIOP – If you are writing most of your new applications using the Java programming language, but need to maintain legacy applications written in other programming languages as well, you will probably want to use Java RMI with its IIOP compiler option.Choice 2 is incorrect because this is not a standard feature of RMI. Choice 3 is incorrect because it can be done. You don’t need to use JNI to do this so choice 4 is incorrect. At present the existing systems all use CORBA. Therefore it is better to use Java IDL. Hence choice 5 is also incorrect.

154 : 2 is correct.
Explanation:
Object mapping is the process of building object wrappers around legacy interfaces. This makes the legacy system available in an OO fashion. You need access to the legacy systems source code in order to do this.A screen scraper emulates a mainframe terminal. Basically the screen scraper logs on to the mainframe like a normal user and sends requests to the mainframe and then reads the response. The problem with a screen scraper is that if you change any of the mainframes code there is always the possibility that the screen scraper will stop working.Any change to the mainframe might break the screen scraper and screen scrapers are only really used when you don’t have access to the mainframes source code so choice 1 is incorrect. Choice 3 is incorrect because you would use a screen scraper if you didn’t have access to the mainframes source code. In choice 4 you would probably use a screen scraper.

155 : 4 is correct.
Explanation:
An off-board server is simply a proxy server for a legacy system.

156 : 8 & 9 is correct.
Explanation:
The controller could be implemented as either a Servlet or a Stateful Session Bean but it makes more sense from a resources point of view to implement this as a Servlet. The customer and cinema component need data to be stored permanently so these should be Entity beans. The process of validating the credit card is a service so this should be a Stateless Session Bean. JSP pages is a better choice than the applet because it means that the system can be used by a greater number of people because there is no dependency on the Java plug in.

157 : 4 is correct.
Explanation:
If the calling client does not have a transaction (i.e. the transaction hasn’t already started) a javax.transaction.TransactionRequiredException will be thrown.Choice 1 is incorrect as REQUIRED will create a new Transaction if a transaction does not already exist whereas the question says it must be part of an existing transaction. Choice 2 is incorrect because REQUIRES NEW will create a new Transaction anyway. SUPPORTS will not force the method to execute in a transaction. Hence choice 3 is also incorrect.

158 : 2 is correct.
Explanation:
As the name suggests”NEVER” is the right answerChoice 1 is incorrect because leaving the deployment descriptor empty is not the default for NEVER. NOT SUPPORTED just suspends the transaction making choice 3 incorrect. NO_TRANSACTIONS is not a valid attribute. Hence choice 4 is also incorrect.

159 : 4 is correct.
Explanation:
This Factory Method pattern provides an interface for creating an object that allows either sub classes or helper classes to create that object.The Singleton pattern creates either 1 or a variable number of instances of a class. So choice 1 is incorrect. The Façade pattern provides a simple interface to a complex subsystem. Thus choice 2 is incorrect. The Builder pattern separates the construction and representation of an object. The client is shielded from the object’s construction and it only needs to specify content and type. Hence choice 3 is also incorrect.

160 : 1 is correct.
Explanation:
The key to this question is that the applet is only connecting back to the server it was downloaded from, and reading a file. This has always been permitted and is permitted with both JDK 1.3 and 1.4. The applet wouldn’t be allowed to read a file on the client’s machine or connect to machines other than the one it was downloaded from.Note: You may think that if the applet has been downloaded then it must automatically be the latest one, this isn’t true as most browser cache applets.

161 : 3 is correct.
Explanation:
When you use Bean Managed Persistence you are writing all the SQL needed to persist the bean yourself. This means that the SQL would have been tailored to the data store you are using and the same SQL might not work with a different database vendor. You can cancel this out by using a Data Access Object. The Data Access Object pattern (DAO) is used to reduce the dependency between Enterprise Beans and the underlying database. This means that the data object manages the connection to the data source and if the data source changes you only need update this one object, the change doesn’t affect the rest of your application.

162 : 1 & 7 is correct.
Explanation:
ACID stands for Atomic, Consistent, Isolatable and Durable. All transactions must adhere to this. Atomic means ‘a transaction must execute completely or not at all.’ Consistent means ‘the integrity of the underlying data source is always maintained.’

163 : 2 is correct.
Explanation:
The most likely explanation here is that your company’s firewall is filtering your requests out based upon your IP address. You would need to get your home IP address added to the list that the firewall trusts (and this won’t be easy if you’re using DHCP!)Choices 1 and 3 are both possible but not the very likely here. Hence these answers are incorrect. Choices 4 and 5 are not factually correct.

164 : 4 is correct.
Explanation:
A bean normally represents a row in the database. Each field that is persisted is typically mapped to a database. The bean itself is not stored in the database, as the class is the same for all bean instances of the same type…it’s just the values that change. If beans were serialized when they where stored on the database you would have to de-serialize each one when you were doing a find operation (by criteria). When Entity Beans are passivated (the state to the bean is written to file), serialization may be used depending on the Application server, although most servers probably also synchronize the state with the database as well.Storing them in memory is not persistence. If the server crashes, all the data would be lost. Therefore choice 1 is incorrect. As Entity beans are persisted, choice 2 is incorrect. Choices 3 and 5 are incorrect because Entity Beans are not serialized.

165 : 2 is correct.
Explanation:
Entity Beans start in the pooled state (this is assuming that the no-args constructor and setEntityContext method has been called). Then when ejbActivate() is called, they move into the ready state and return to the pooled state when ejbPassivate() is called.

166 : 1 is correct.
Explanation:
The Home interface defines the create(), find(), and remove() methods and the finder methods are used for locating beans.The Remote Interface is used to define all of the methods that can be called by the client on the Enterprise Bean. If you try and call a method that exists in the Enterprise bean class but not in the Remote Interface, you will get a RemoteException.

167 : 1 & 2 is correct.
Explanation:
The Home interface defines the create(), find(), and remove() methods.The Remote Interface is used to define all of the methods that can be called by the client on the Enterprise Bean. If you try and call a method that exists in the Enterprise bean class but not in the Remote Interface, you will get a RemoteException.Choice 3 is incorrect because the find method in the Home interface returns an EJBObject or an Enumeration. Choice 4 is incorrect because ejbFind() returns the Primary Key. The find methods are not defined in the Remote interface so choices 5 and 6 are incorrect.

168 : 3 is correct.
Explanation:
As you are able to connect to your desktop PC you know that your company doesn’t filter traffic based upon IP address. Therefore the most likely reason you can’t connect is because you are requesting a different port and the firewall is filtering that traffic.Although it’s possible that a typing error in the connection details may be stopping you connecting it isn’t the most likely reason. So choice 1 is incorrect. You wouldn’t be able to connect to your desktop PC if your company was filtering traffic based upon IP address. So choice 2 is incorrect. When you connect to your application from within the office you are still connecting via a socket. So you would not be able to connect at work either if there was a problem with the security manager. Hence choice 4 is incorrect. Although choice 5 is possible it is not the most likely reason.

169 : 2 is correct.
Explanation:
The key to the question is what does Java allow you to do. Java has no direct relationship with CORBA so the answer is False. However if the question was rephrased slightly for example using Java is it possible to tunnel IIOP over HTTP then the answer would be True (most firewalls are configured to only let HTTP / HTTPS requests through)

170 : 5 is correct.
Explanation:
Even if the code is signed, the browser’s policy file may refuse it permission to perform certain tasks. The policy file will need to grant necessary permissions such as:grant signedBy”signingKey” { Permission java.io.FilePermission”local_file”,”read”;}to allow the applet to read local files.Choice 1 is incorrect because it depends on the browsers security policy file. Choice 2 is incorrect because the security manager might not prohibit this. The applet wouldn’t automatically be able to read the file. So choice 3 is incorrect. It would matter which certificate authority signed it, if you have not chosen to trust a particular certificate authority the code might as well not be signed at all! So choice 4 is also incorrect.

171 : 2 is correct.
Explanation:
As there is no reference to this being a web based solution and all of the staff are in the same office there is no need to use HTTPS. JRMP is the most appropriate answer.There is no mention of the need for Entity Beans or interfacing with a CORBA system so choice 1 is incorrect. Choices 3 and 4 are incorrect because this is not being used over the web.

172 : 3,6 & 7 is correct.
Explanation:
The following is taken from Core J2EE Patterns: Best Practices and Design Strategies page 369 “Use a Service Locator object to abstract all JNDI usage and to hide the complexities of initial context creation, EJB home object lookup, and EJB object re-creation. Multiple clients can reuse the Service Locator object to reduce code complexity, provide a single point of control, and improve performance by providing a caching facility.”Choice 1 is describing a standard web based login but this has nothing to do with the Service Locator pattern. Choice 2 sounds plausible but this is not how the Service Locator pattern is used. Choice 4 is incorrect as there is an increase not a loss of performance when using this pattern. Choice 5 is incorrect as there are accurate descriptions of the Service Locator pattern amongst the answers.Some useful links: http://developer.java.sun.com/developer/technicalArticles/J2EE/patterns/

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.

173 : 1 is correct.
Explanation:
Tunnelling is used to pass one protocol through a port that it does not, by default run on. For example if the only free port on the firewall was port 80 and you needed to pass JRMP through the firewall you would “tunnel” JRMP through the firewall. (JRMP by standard runs on port 1099). Basically JRMP would run on top of HTTP. However Tunnelling should generally be avoided and should only be used as a last resort. You use tunnelling when you don’t have access to a particular port. So choice 3 is incorrect. RMI-IIOP is unrelated to tunnelling. Choice 2 is incorrect because stealing the key from the guard would be easier!

174 : 4 is correct.
Explanation:
DMZ stands for Demilitarized zone. To set up a DMZ you need two firewalls with which you create 3 separate regions. The different regions are the internet, DMZ (in the middle) and your network. You would have a server in the DMZ that would be accessible to both the public and employees in your local network. The internet connections will not have access your network though they will be able to access the server in the DMZ. Your network will access the internet through the server in the DMZ.Choice 1 is just describing the process of using a firewall. The region described in choice 2 is your network the DMZ is the area between the two firewalls. Choice 3 describes the internet not a DMZ.A Useful link: http://www.saintrochtree.com/network-advices/000004.htm

175 : 2 is correct.
Explanation:
The key to this question is that there are no transactions and there is no data to persist. All you are sending to the client are HTML web pages; even if you were to use JSPs/Servlets you still wouldn’t use an Application server. In a situation like this you have to think of what the Application server should actually do? In this case there is nothing for it to do.

176 : 2 is correct.
Explanation:
It is impossible to make sweeping statements such as Java is always the best solution for 3-tier architectures. A project needs to be looked at individually and then assessed. You may think that one project naturally suits a full Java implementation only to find out that a company has already heavily invested in a different technology or that you don’t have the resources (employees with skills in Java based technologies) to implement a solution.

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

*