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

SCEA Mock Exams - 4

 76    You need to replace ASP scripts. What J2EE technology do you use?

 

A     JMS, JSP and Servlets

B     JSP and Servlets

C     JTA, JSP and Servlets

D     Applets

 

Choice B is correct.

 

ASP and JSP have a very similar syntax so it makes sense to replace ASP with JSP. You should also try and extract parts from the ASP script that perform controller operations or other processing and implement them as Servlets.Choice A is incorrect because the Java Message Service and has nothing to do with web pages. There is no mention of transactions in the questions and if there was it would probably be better to use EJBs as well so choice C is incorrect. Although choice D is possible this is not the best answer as there would be too much work involved in creating the Applets.

 

 

 

 

77    As part of your new application you need to connect to a database. You don't have any access to the database server so you can't change the ODBC driver that's currently installed. How do you connect?

 

A     CORBA

B     JMS-JNI

C     JDBC-ODBC bridge

D     JDBC

 

Choice D is correct.

 

The key to this question is that you don't need to install a new ODBC driver or anything like that, you can connect to the database directly via JDBCCORBA is used for distributed systems not database connectivity so choice A is incorrect. Choice B wouldn't work and choice C isn't necessary, as the question doesn't say that you can't use a normal JDBC driver.

 

 

 

78    When would you choose RMI-JRMP over CORBA?

 

A     When you are designing a pure Java solution.

B     When you are designing a solution that will not be pure Java but will mainly be in Java.

C     When you will interact with applications written in other languages such as C/C++

D     When performance is essential.

 

Choice A is correct.

 

The following is taken from:http://java.sun.com/j2se/1.3/docs/guide/idl/index.htmlThis is a fundamental question and it's important to understand the distinction between these two ways of integrating the Java programming language with CORBA. Java IDL is for CORBA programmers who want to program in the Java programming language based on interfaces defined in CORBA Interface Definition Language (IDL). This is "business as usual" CORBA programming, supporting Java in exactly the same way as other languages like C++ or COBOL. RMI-IIOP (Remote Method Invocation over Internet Inter-ORB Protocol) is for Java programmers who want to program to the RMI interfaces, but use IIOP as the underlying transport. RMI-IIOP provides interoperability with other CORBA objects implemented in various languages - but only if all the remote interfaces are originally defined as Java RMI interfaces. It is of particular interest to programmers using Enterprise JavaBeans (EJB), since the remote object model for EJBs is RMI-based.You would use RMI-IIOP in choice B. In choice C you would use CORBA. CORBA actually slightly outperforms RMI. Hence choice D is also incorrect.

 

 

 

 

79    You have a distributed system that is not made up entirely of Java objects (some of them are CORBA) what technology should you use?

 

A     RMI-JRMP

B     CORBA

C     Rewrite the objects so the system in entirely Java based

D     RMI-IIOP

 

Choice B is correct.

 

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 AnywhereTM" 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.RMI-JRMP would be used in an all Java solution so choice A is incorrect. There is no need to rewrite the objects so the system in entirely Java based so choice C is incorrect. There already are CORBA objects so although choice D is possible it is not the most appropriate answer.

 

 

 

 

80    When would you use a JDBC-ODBC Bridge?

 

A     This is the standard, and is used all the time.

B     When you have to use a database that has an ODBC driver but the JDBC driver doesn't exist.

C     When you are connecting to a database running on a Windows server (NT, 2000 etc).

D     When you need faster response times.

 

Choice B is correct.

 

You are basically connecting to the ODBC driver as opposed to directly to the database.Choice A is incorrect; normally you would just connect directly via JDBC. Whether you are connecting to a database running on a Windows server (NT, 2000 etc) makes no difference at all. Hence choice C is incorrect. The JDBC-ODBC bridge will not increase performance as described in choice D.

 

 

 

 

81    You have had enough with all the UML tools on the market as none do exactly what you want them to. So you've decided to design your own. However when designing it you realise that certain parts will be really complicated for example you have a Diagram object that is made up of lots of other objects. This diagram object can be used for a variety of different diagrams including class and sequence diagrams. When you create it you only want to specify its type and content. What pattern should you use?

 

A     Abstract Factory

B     Factory Method

C     Builder

D     Decorator

 

Choice C is correct.

 

The builder pattern separates the construction and representation of an object. The client is shielded from the objects construction only needing to specify it's content and type.The Abstract Factory pattern is used for creating many objects that are dependent on each other. Hence choice A is incorrect. The Factory Method pattern provides an interface for creating an object that allows either sub classes or helper classes to create that object. Hence choice B is also incorrect. The Decorator pattern isn't used to build objects. It adds extra functionality to existing objects. Hence choice D is incorrect.

 

 

 

82    You need to interface with an existing application. You have full access to the source code and UML diagrams from the existing application. Part of the requirements implies that you will need to connect unrelated objects together. You want to know whether the Bridge pattern or the Adapter pattern will be suitable. Which of the following are true about the Bridge and Adapter patterns?

 

A     The Adapter pattern implements an interface known to its clients and provides an instance of a class not known to its clients.

B     The Bridge pattern implements an interface known to its clients and provides an instance of a class not known to its clients.

C     The Adapter pattern creates a separation between abstractions and classes that implement those abstractions.

D     The Bridge pattern creates a separation between abstractions and classes that implement those abstractions.

 

Choices A and D are correct.

 

As the answers state the Adapter pattern implements an interface known to its clients and provides an instance of a class not known to its clients. And the Bridge pattern creates a separation between abstractions and classes that implement those abstractions. Choices B and C are incorrect because the descriptions are the other way around.

 

 

 

83    As part of your new application you need to create a custom class loader so that you can implement with custom security. So you need to create objects without knowing the class of the objects or how to create them. What pattern should you use for this?

 

A     Abstract factory

B     Factory Method

C     Builder

D     Prototype

E     Singleton

 

Choice D is correct.

 

This pattern is used to create new objects by copying its prototype.The Abstract factory pattern is used for creating many objects that are dependent on each other. Therefore choice A is incorrect. The Factory Method pattern provides an interface for creating an object defers creation to either sub classes or helper classes. Hence choice B is incorrect. The Builder pattern separates the construction and representation of an object. The client is shielded from the objects construction only needing to specify it's content and type. Choice C is therefore incorrect. The Singleton pattern creates either one or a variable number of instances of a class making choice E incorrect.

 

 

 

84    You are creating a web application for an online product ordering system. You will be using data from several different databases and to reduce the load on the databases you have decided to use connection pooling. You have a ConnectionPool class and you want one pool for each database however you will have to connect to a variable number of databases. What pattern should you use?

 

A     Abstract factory

B     Factory Method

C     Builder

D     Prototype

E     Singleton

 

Choice E is correct.

 

The Singleton doesn't just create a single instance it can also be used to create a variable number of instances of a class.The Abstract factory pattern is used for creating many objects that are dependent on each other so choice A is incorrect. The Factory Method pattern provides an interface for creating an object defers creation to either sub classes or helper classes. Hence choice B is incorrect. The Builder pattern separates the construction and representation of an object. The client is shielded from the objects construction only needing to specify it's content and type. Choice C is hence incorrect. The Prototype pattern is used to create new objects by copying its prototype. Choice D is therefore incorrect.

 

 

 

85    You are interfacing with a server that is running as a JMS server and email server. Basically your company has an online shopping store and when a customer buys something you need to send an email confirmation. Email requests will be sent as JMS messages so as to reduce the load on the email server. Does JMS provide the implementations to allow you to send these messages to the email server? True/False?

 

A     TRUE

B     FALSE

 

The above statement is False.

 

The JMS only defines interfaces there are no implementation classes in the package. So you will need to write all of the implementations yourself.

 

 

 

86    Is Point-to-Point (PTP) is based on message queues?

 

A     TRUE

B     FALSE

 

Choice A is correct.

 

Point-to-Point messaging is typically used where a client application sends a message to another application. This is the one-to-one messaging paradigm. In contrast, Publish Subscribe, allows broadcast communication (one-to-many.)

 

 

 

87    Your have decided to let people shopping at your site receive confirmation emails when they buy online. The emails will not contain their credit card numbers but will contain the amount they have been charged. A JMS request to an email server will be used to do this. However you are worried about how secure this will be but a college re-assures you that JMS has security built into it. Is this true? True/False?

 

A     TRUE

B     FALSE

 

 

The above is false.

 

The JMS only defines interfaces so you will need to design your own security around this.

 

 

 

88    You've designed an application that allows customers to buy chapters of e-books. Due to the success of the project this will be launched as a worldwide application. In the process of converting this application to be suitable for worldwide use, which of the following will you use?

 

A     Java runs with already as standard 16bit characters as standard so you don't need to use any particular classes to change the text. All primitive objects can be used.

B     java.text package

C     java.lang.Integer Class

D     java.lang.Number Class

E     java.international package

F     java.Unicode package

 

Choice B is correct.

 

The java.text package contains classes such as MessageFormat and NumberFormat, these classes are used to layout text in the appropriate way.Choice A is incorrect; primitive objects cannot be used. Choices C and D are incorrect because the way numbers are displayed is different in most countries. The packages named in choices E and F don't exist.

 

 

 

89    Which of the following are used in Internationalization?

 

A     java.lang.Long Class

B     java.lang.Float Class

C     java.lang.Number Class

D     java.lang.String class

E     char primitive class

 

Choices D and E are correct.

 

The String and char primitive classes are used in the process of Internationalization.Choices A, B and C are all incorrect because its the way numbers are displayed that is different in most countries.

 

 

 

90    What is the ResourceBundle class used for?

 

A     To store information about the program, like an external configuration file.

B     To store parts of the program that is Locale sensitive, e.g. the text on a message window.

C     To get access to local system resources such as files etc.

D     To access properties of the users environment, language and a region.

 

Choice B is correct.

 

A ResourceBundle is used to store all parts of a program that you will need to change as part of Internationalization. For example you could put the text for dialog messages there and when it came to displaying the dialog, the program will look up and retrieve the appropriate text based on the country of the user.Choice A is incorrect because the ResourceBundle doesn't store any information about the program like an external configuration file. The ResourceBundle doesn't give you any access to local resources. Hence choice C is incorrect. The properties of the user's environment, language and a region are found in the users system properties, not the ResourceBundle. Hence choice D is also incorrect.

 

 

 

 

91    You have been brought in from another project to help some colleagues with the documentation of an application they have been working on. You need to show groups of classes as subsystems. What type of UML diagram will you use?

 

A     Collaboration Diagram

B     Class Diagram

C     Package Diagram

D     Use case Diagram

 

Choice C is correct.

 

A package diagram is used to show groups of classes that belong together. Choice A is incorrect because a Collaboration Diagram is a type of interaction diagram. A Class Diagram shows individual classes. Hence choice B is incorrect. A Use case Diagram depicts a scenario that the system would be involved in. Thus choice D is also incorrect.For more information about UML:http://www.uml.org/

 

 

 

 

92    What is true about the following diagram?

 

A     Class A inherits from Class B

B     Class B inherits from Class A

C     Class B will send messages to Class A

D     Class A will send message to Class B

 

Choice B is correct.

 

This diagram shows generalization (or inheritance). Note: Normally the sub class is be shown below the ancestor, though that is not a UML constraint.Choice A is incorrect because it is the other way around. Choices C and D are both incorrect because the empty triangle wouldn't be there in the diagram if messages were being sent.For more information about UML:http://www.uml.org/

 

 

 

 

 

 

 

 

 

93    What is the "Something" shown in the following diagram?

 

A     A component

B     A package

C     A component collaboration

D     A super class

 

Choice B is correct.

 

This is a package and it represents a group of classes.The symbol is incorrect for it to be a component. Hence choice A is incorrect. For this to be part of a collaboration diagram it would need to interact with another object. Hence choice C is incorrect. If it were a super class, another class would need to extend from it. So choice D is also incorrect.For more information about UML:http://www.uml.org/

 

 

 

94    What is true about the following diagram?

 

A     It is a class called AName

B     It is a static class called AName

C     It is an object called AName

D     It is an interface

 

Choice C is correct.

 

You can tell this is an object because its name is underlined. The following is taken from (Cade 42):"If the element name is underlined, then it is an instance of an element. You can precede an element name with a : and have an anonymous instance. You can place a name in front of the : and have a named instance of an element."Choices A and B are incorrect because the name is underlined. Choice D is incorrect because the symbol would have the word interface above it like this: <<interface>> if it were an interface.For more information about UML:http://www.uml.org/

 

 

 

 

 

 

 

 

 

95    When should you use Java IDL and when should you use RMI-IIOP?

 

 

A     You should use Java IDL when using Enterprise Javabeans.

B     You should use RMI-IIOP when using Enterprise Javabeans.

C     You HAVE to use RMI-IIOP when using Enterprise Javabeans.

D     Java IDL can be used even if the remote interfaces were originally defined as RMI interfaces.

E     RMI-IIOP can be used with CORBA only if the remote interfaces were originally defined as RMI interfaces.

F     RMI-IIOP can be used with CORBA even if not all of the remote interfaces were originally defined as RMI interfaces.

G     It comes down to programmer preference as both can be used in all situations.

 

Choices B and E are correct.

 

The following is taken from:http://java.sun.com/j2se/1.3/docs/guide/idl/index.htmlThis is a fundamental question and it's important to understand the distinction between these two ways of integrating the Java programming language with CORBA. Java IDL is for CORBA programmers who want to program in the Java programming language based on interfaces defined in CORBA Interface Definition Language (IDL). This is "business as usual" CORBA programming, supporting Java in exactly the same way as other languages like C++ or COBOL. RMI-IIOP (Remote Method Invocation over Internet Inter-ORB Protocol) is for Java programmers who want to program to the RMI interfaces, but use IIOP as the underlying transport.

 

RMI-IIOP provides interoperability with other CORBA bjects implemented in various languages - but only if all the remote interfaces are originally defined as Java RMI interfaces. It is of particular interest to programmers using Enterprise JavaBeans (EJB), since the remote object model for EJBs is RMI-based. Choice A is incorrect; Java IDL has nothing to do with Enterprise Javabeans. In choice C you can use JRMP instead of IIOP if you want. So this choice is incorrect. Choice D is incorrect because Java IDL requires CORBA interfaces not RMI interfaces. Choice F is incorrect as all the interfaces must be defined as RMI interfaces. Choice G is incorrect because although sometimes Java-IDL and RMI-IIOP could be used for the same thing, generally a situation will suit one more than the other.

 

 

 

 

 

 

 

96    You have an online shopping application that has been deployed for some time. Previously all sales had been diverted to another company. Because of the popularity of your site now, you have decided that your application will handle credit card sales, going forward. You will use JMS to send requests to charge credit cards to a separate server. You need an instant response as to whether the credit card transaction was approved. What type of messaging do you use?

 

A     Publish/Subscribe

B     Point-to-Point

C     Topic Messaging

D     Instant Messaging

E     You wouldn't use messaging

 

Choice E is correct.

 

If you need an instant response you probably wouldn't use messaging. The idea of messaging is that you can send messages to other applications and let them process the messages in their own time. For this solution it will be better to use an EJB and directly query the credit card validation server.Choice A suggests that messages will be broadcast (one-to-many.) For credit card validations, there is no need to broadcast the request. Besides the question says that an"instant response is required." Messaging is inherently asynchronous. Hence choice A is incorrect.Point-to-Point or P2P is a one-to-one messaging architecture. JMS does provide APIs that allow send-and-forget and send-and-respond messages. Though a synchronous request is mimicked here, messaging architecture, unlike RPC models, is not truly synchronous.

 

Note: In some P2P implementations (where a synchronous response is required using messaging), the sender puts the message in a queue. The receiver polls its queue and reads the message. The receiver then sends a response to another queue, which the sender is polling for responses and so on. So though the credit card validation can be achieved through P2P messaging, if a synchronous RPC call is available, that would be the preferred option.Topic Messaging is the same as Publish Subscribe. Hence choice C is incorrect. Instant Messaging refers to a method of chatting on the Internet. Hence choice D is incorrect.

 

 

 

 

97    You are working for a company that aims to provide its customers with the facility to buy and sell shares online. You have been looking through the requirements document and notice that the process of selling/transferring shares is very complicated due to the constant price change. Hence you are required to control transactions at a very fine level of granularity. Should you use CMT or BMT?CMT = Container Managed TransactionBMT = Bean Managed Transaction

 

A     CMT

B     BMT

 

Choice B is correct.

 

BMT gives you the developer much greater control over the transaction. As the developer, you can start the transaction where you want and end it where you want.CMT does however give you the advantage of not having to worry about code related to the transaction you can just focus on the business logic instead.The following is taken from: http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Transaction4.html

 

In a bean-managed transaction, the code in the session or message-driven bean explicitly marks the boundaries of the transaction. An entity bean cannot have bean-managed transactions; it must use container-managed transactions instead. Although beans with container-managed transactions require less coding, they have one limitation: When a method is executing, it can be associated with either a single transaction or no transaction at all. If this limitation will make coding your bean difficult, you should consider using bean-managed transactions.

 

 

 

 

 

 

98    You have contracted by a company to assess an application currently deployed in production. The application meets all of the company's original requirements and is coping well with the current number of users. The company is quite happy with it. It has been written using PERL and CGI scripts and there are no transactions in this system. What do you recommend they do?

 

A     Migrate the solution to ASP based solution.

B     Migrate the solution to JSP and Servlets. In the future this will be more maintainable solution.

C     Keep it the way it is.

D     Migrate to JSP/Servlets and an Application server. In the future this will be more maintainable solution.

 

Choice C is correct.

 

The key to this question is:The application meets all of the company's original requirements and is coping with current number of users. The company is quite happy with it.There is no need to change an application that does everything it is supposed to do. Choice B is technically correct, JSP and Servlets will be more maintainable than PERL/CGI scripts but it is not the most appropriate answer. Choice D isn't correct for the same reasons as choice B, in addition to the fact that there appears to be no clear need for using an Application Server (there are no transactions and there is no mention of persistence requirements.) Choice A is also incorrect for the same reasons as choice B.

 

 

 

 

 

 

 

 

 

 

99    You have been contracted by a company to examine an existing system. It consists of PL/SQL stored procedures a JSP/Tomcat cluster of web servers and an Oracle database. The owners are saying that maintenance is their biggest problem, every time they try and change code they run into problems. What do you recommend they do?

 

A     Move the PL/SQL business logic into Servlets

B     There shouldn't be any problems with maintenance as the business logic has already been separated from the presentation and data store (PL/SQL stored procedures).

C     Separate the business logic by using an Application Server.

D     Look through the code making sure it is structured well and commented, separating any duplicated code into a common class.

 

Choice C is correct.

 

The key to this question is that the business logic has been implemented as PL/SQL stored procedures. This means there is a tight coupling between the data store and the business logic. This will have a direct affect on the maintenance of the application. To improve this the best thing to do would be move the business logic from the PL/SQL scripts to an Application Server and use Enterprise Beans. Another reason why this is the best choice is because they are already using JSP and Tomcat web servers. So the Application Server will integrate well into this solution. You could move the business logic into Servlets as suggested in choice A but this would create tight coupling between the business logic and presentation code. The application would still be hard to maintain, with problem areas at a different place. Choice B is incorrect as there is tight coupling between the data store and business logic. Even if the code is properly structured and commented there will still be tight coupling between the data stoe and business logic so choice D is incorrect.

 

 

 

 

100   You have a method that can execute in a transaction as part of that transaction but it doesn't matter if it doesn't. What is the correct attribute in the deployment descriptor?

 

A     Supports

B     Not Supported

C     Mandatory

D     Required

E     Leave is empty as this is the default setting

 

Choice A is correct.

 

A method must support execution within a transactional scope, if it is to be executed as part of a transaction. The word 'supports' also implies that although it can be part of a transaction, it doesn't have to. 'Not Supported' implies the method cannot be executed as part of a transaction. 'Mandatory' and 'Required' imply that the method must be executed as part of a transaction. Leaving the deployment descriptor empty is not the default setting for 'supports.'


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