Top Banner
ADVANCE JAVA – DESIGN PATTERN 1.Which of the following best describes a Design pattern? a) Provide common communication platform between objects b) Provide good look and feel of the application c) Introduce complex relationship between objects d) Create specialization in software development e) Tightly couple the objects 2.MVC Stands for________________.? a) Model-View-Controller b) Memory-Virtual-Control c) Master-View-Controller d) Method Invocation - View Selection - Change Notification e) Model - View – Client 3.Which of the following does adopting MVC architecture to a J2EE application allow? a) Interweaving business and data access b) deploy components separately in the servers
29
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Sample Questions Advance Java-Design Pattern

ADVANCE JAVA – DESIGN PATTERN

1.Which of the following best describes a Design pattern?

a) Provide common communication platform between objects

b) Provide good look and feel of the application

c) Introduce complex relationship between objects

d) Create specialization in software development

e) Tightly couple the objects

2.MVC Stands for________________.?

a) Model-View-Controller

b) Memory-Virtual-Control

c) Master-View-Controller

d) Method Invocation - View Selection - Change Notification

e) Model - View – Client

3.Which of the following does adopting MVC architecture to a J2EE application allow?

a) Interweaving business and data access

b) deploy components separately in the servers

c) separate core business model functionality from the business presentation and control logic that uses the functionality

d) To recreate the objects in every layer by copying and pasting

e) to compile objects separately

4. Design pattern suggests that you always program to an interface and not to an implementation.

State True or False.

Page 2: Sample Questions Advance Java-Design Pattern

a) True

b) False

  5. Design pattern does not provide reusable solution to commonly encountered programming challenges.

State True or False.

a) True

b) False

 6. We use design patterns to fit non-functional requirements in efficient object models in an enterprise application.

State True or False.

a) True

b) False

 7.____________ represents enterprise data and the business rules that govern access/updates to the enterprise data.

a) View

b) Model

c) Controller

d) Events

e) State

8. View is responsible for calling the model. When it needs to retrieve most current data then it is called as _____________

a) Pull model

b) Push model

c) View model

d) HTTP model

Page 3: Sample Questions Advance Java-Design Pattern

e) GUI model

9."View renders the contents of a model". State True or False.

a) True

b) False

10. Separating core business model functionality from the presentation and control logic allows __________________.

a) multiple views to share the same enterprise data model

b) single view to have multiple data

c) flexibility to carryout changes in deployment environment

d) monitor changes efficiently

e) create employment opportunities

11. For which of the following a Singleton pattern is not used for ?

a) An object that caches only data for an application.

b) Creating only a single instance of a class.

c) An object that has no state but has some calculation.

d) Creating multiple instances of a class.

12. Which of the following is the primary disadvantage of a Singleton pattern?

a) It allows multiple instances of the class.

b) It allows only one instance of the class.

c) It does not allow any instance of the class.

d) None of the listed options.

 13. Which of the following is NOT a valid design pattern type?

Page 4: Sample Questions Advance Java-Design Pattern

a) Fundamental

b) Presentation

c) Behavioral

d) Accidental

e) None of the listed options

14. Service Locator Pattern can improve performance by caching factory and context objects.State True or False.

a) True

b) False

 

15. The pattern that decouples the presentation tier and business service tier is _______________.

a) Value Objects

b) Iterator

c) Adaptor

d) Front Controller

e) Business Delegate

16.Which web tier pattern accommodates view selection and security?

a) MVC Pattern

b) Front Controller

c) Business Objects

d) Data Access Objects

e) None of the listed options

17. The HomeInerface of EJB used factory pattern. The create method is the factory method.State True or False.

Page 5: Sample Questions Advance Java-Design Pattern

a) True

b) False

  18. MVC Pattern is used in Java Swing API. State True or False.

a) True

b) False

  19. Which pattern allows you to replace the presentation logic without much impact on the data representation?

a) Model - View - Controller

b) Business Delegate

c) Transfer Objects

d) Data Access Objects

e) None of the listed options

f)

20. ValueObjectFactory/ValueObjectAssembler Pattern is NOT used to avoid multiple network calls for a single client request.State True or False

a) True

b) False

 21. Data Access Objects does not decouple client interface from underlying data access mechanics. State True or False.

a) True

b) False

 22. Data Access Objects pattern is used to access different data sources. State True or False.

a) True

Page 6: Sample Questions Advance Java-Design Pattern

b) False

 23. The Composite Entity design pattern does not offer a solution to modeling a networks of interrelated business entities.State True or False.

a) True

b) False

 24. Using session facades whenever EJB components are used is NOT a good practice.State True or False.

a) True

b) False

  25. Which of the following regarding Design Pattern is correct?

a) Business Delegate - Reduces the coupling between presentation-tier clients and business services

b) Data Access Object - Allows for Multiple Views using the same model

c) MVC - Enables easier migration to different persistence storage implementations

d) Value Object - Increases the network overhead

e) None of the listed options

26. having Data Access Objects are best suited for business logic of application which is dependent on data structures in the data base. State True or False.

a) True

b) False

 27. Use Session Façade Pattern to avoid direct client access to Entity beans thus reducing network calls.State True or False.

a) True

b) False

Page 7: Sample Questions Advance Java-Design Pattern

 28. Which of the following characterizes Behavioral patterns?

a) Behaviors of objects

b) Attributes of Java beans

c) How objects communicates with each other

d) How behaviors of objects can be controlled in a distributed environment.

 29. Which of the following characterizes Structural patterns?

a) How classes and interfaces can be combined to form larger structures

b) How objects can be combined to form larger structures

c) How components can be arranged to make another components

d) None of the listed options

 30. In Service Location pattern, the look up operation is done by _________________.

a) the client

b) the service locator

c) a component interface

d) business delegate

 31. Use ValueListHandler Pattern to avoid using Entity beans and send data iteratively to the client.State True or False.

a) True

b) False

 32. You use ServiceLocator/EJBHomeFactory Pattern to reduce expensive JNDI lookup process.

State True or False.

a) True

Page 8: Sample Questions Advance Java-Design Pattern

b) False

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

a) Abstract Factory

b) Singleton

c) MVC

d) Business Delegate

e) All of the listed options

34. Which pattern is a serializable class that groups related attributes, forming a composite value?(This class is used as the return type of a remote business method)

a) Transfer Object

b) Session Façade

c) Business Object

d) Singleton

e) None of the listed options

35. Which of the following pattern defines an interface for creating an object, but let the subclasses decide which class to instantiate?

a) Factory Pattern

b) MVC Pattern

c) Creator Pattern

d) Instantiator Pattern

e) None of the listed options

36. Which of the following pattern reduces coupling between Web and EJB tiers?

a) Front Controller

Page 9: Sample Questions Advance Java-Design Pattern

b) Adapter

c) Transfer Object

d) Façade

e) Business Delegate

37. When we implement an EJB in a class that extends Session Bean or a Entity Bean, EJB container uses Adaptor pattern for providing declarative transaction and persistence support.

State True or False.

a) True

b) False

38. Which of the following can be termed as Advantages of View Helper ?

a) Improves maintainability by providing clearer

separation of view from business processing

b) Better code reuse

c) Improves better role separation for

development staff

d) Can use tag libraries

e) All of the listed options

39. Which pattern is used to hide the underlying implementation details of the business service, such as lookup and access details of the EJB architecture from client?

a) MVC Pattern

b) Value Objects

c) Transfer Objects

Page 10: Sample Questions Advance Java-Design Pattern

d) Business Delegates

e) None of the listed options

40. Front Controller does not fulfill security needs of web tier.State True or False.

a) True

b) False

  41. Which pattern defines a higher-level business component that contains and centralizes complex interactions between lower-level business components ?

a) Business Delegate

b) Business Object

c) Session Façade

d) Front Controller

e) None of the listed options

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

a) The factory method makes objects that should be used together. This is not the case for the abstract factory.

b) The abstract factory pattern provides an interface for creating a family of objects whereas factory method provides

an interface for creating one object

c) 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

d) 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

e) None of the listed options

43. Which object pattern is used to avoid multiple calls made to obtain business data and avoid associate overheads?

Page 11: Sample Questions Advance Java-Design Pattern

a) Entity Beans

b) Session Beans

c) MVC pattern

d) Transfer Object pattern

e) Remote pattern

44. Which of the following combinations (Design Pattern - Usefulness) regarding Design Patterns are correct? (Choose 2)

a) Business Delegate - Reduces the coupling between presentation-tier clients and business services

b) Data Access Object - Allows for Multiple Views using the same model

c) MVC - Enables easier migration to different persistence storage implementations

d) Value Object - Reduces Network Traffic

 45. When you are learning about design patterns, 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?

a) Singleton

b) Session Façade

c) Business Object

d) Factory Method

e) Value Object

46. Which of the following is true with respect to attributes in transfer objects?

a) It is always necessary to declare all the attributes public

b) All the attributes should be declared private

c) It is a design choice and to be analyzed according to the needs

d) Transfer object should not contain any attributes.

e) None of the listed options

Page 12: Sample Questions Advance Java-Design Pattern

47. Which of the following are true about Composite View pattern?(Choose 3)

a) There is no such pattern

b) Composite View patterns have enhanced flexibility.

c) Using Composite View patterns, Individual components are easier to manage.

d) Composite View pattern provides better modularity and increased reuse

e) Composite View pattern complicates layout changes

48. What design pattern would be used to reduce JNDI lookups?

a) Service Locator

b) MVC Pattern

c) Business Object Pattern

d) Transfer Object Pattern

e) None of the listed options

49. Which of the following are advantages of Data Access Objects?(Choose 2)

a) Abstracts implementation details

b) Centralizes all data access into single layer

c) Increases code complexity

d) Decreases performance

 50. In distributed applications, lookup and exception handling for remote business components can be complex.When applications use business components directly, application code must change to reflect changes in business component APIs. Which of the following intermediate class solves the above problems?

a) Value Object

b) Business Object

c) Business Delegate

Page 13: Sample Questions Advance Java-Design Pattern

d) Façade

e) None of the listed options

51. When the application service layer throws exceptions, those exceptions are to be translated into meaningful business exceptions.Which of the following pattern facilitates the above requirement?

a) MVC Pattern

b) Business Delegate

c) Value Object

d) Singleton

e) None of the listed options

52. The web application you are developing requires the EJB to populate business data atributes and values.To effectively achieve this requirement, which of the following design pattern is suitable?

a) Business Delegate

b) Front Controller

c) Transfer Objects

d) Singleton

e) None of the listed options

53. In the application you are developing there is 1:1 mapping between entities and tables causing fine grained entity beans.Which of the following pattern is best suitable to have coarse-grained bean interface?

a) Grained Pattern

b) Business Delegates

c) Composite Entity Pattern

d) Singleton

e) Front Controller

Page 14: Sample Questions Advance Java-Design Pattern

54. You are given to develop a component that does many of the pre-processing stuffs like -(a) whether the requests are coming from authentic sources, (b) filtering unwanted data in the request object. What type of pattern will be the best match for developing such a component?

a) Front Controller

b) Business Controller

c) Business Delegate

d) Intercepting Filter

e) None of the listed options

55.When remote calls are made on the container provided implementations of the EJBHome and EJBObject, various transactional and security checks are applied before the call is actually passed on to the bean instance. Which of the following Design pattern's task does the container provided implementations of EJBHome and EJBObject perform?

a) Command

b) Adaptor

c) Bridge

d) Decorator

e) Facade

56. 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) MVC Pattern

c) Singleton Pattern

d) Business Object

Page 15: Sample Questions Advance Java-Design Pattern

e) Prototype pattern

57. You are developing an application that will have to support a huge number of users. You are worried about the performance of the application because you need to use many Entity Beans. You are suggested to use Value Object pattern. Which of the following characteristic makes use of Value Object pattern appropriate?

a) Value object is a snapshot of the state of an Entity Bean at a particular time

b) There is no such thing as a Value Object design pattern

c) There is a Value Object design pattern but it would not be appropriate to use it here

d) A Value Object is the state of an Entity Bean that is kept in memory by the Application Server. (Its state is periodically

persisted.)

e) None of the listed options

58. What are the benefits of using the Service Locator pattern? (Choose 2)

a) The Service Locator pattern can improve performance by introducing a caching facility

b) There is a slight loss of performance when using the Service Locator pattern but this is outweighed by the improved

maintainability of the code

c) The Service Locator pattern is used to hide the complexities of initial object creation, EJB lookups and object re-

creation

d) 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

e) None of the definitions of the Service Locator pattern are accurate

59. You are designing a 3-tier architecture for a new application for an important client. 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

Page 16: Sample Questions Advance Java-Design Pattern

number of users, you have decided to use the Front Controller pattern.

Which of the following statements describe the Front Controller pattern?(Choose 2)

a) Provides a central point of entry

b) The controller manages client requests, security, delegation of business processing, error handling, view selection

and content creation strategies

c) The Front Controller is just another way of describing the Controller out of the Model View Controller architecture

d) 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

 60. Your client has just started business operations in India, To counter competition your client 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 an unified interface to the Entity Beans in the system.

The use of session beans here illustrates the use of what design pattern?

a) MVC

b) Adaptor

c) Facade

d) Decorator

e) None of the listed options

61. 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

Page 17: Sample Questions Advance Java-Design Pattern

c) Façade

d) Flyweight

e) Visitor

62. In a web application, the user performs an action that changes the state of the model.

Which of the following achieves appropriate selection of view, based on the outcome of the model actions?

a) Controller

b) Model and Controller

c) View and Controller

d) Model and View

63. Consider the following code snippet:

public static MyClass get() {if (instance == null) {instance = new MyClass()}return instance;}

Which of the following pattern does the above code represent?

a) Instance pattern

b) Class pattern

c) MVC pattern

d) Singleton pattern

e) Factory pattern

64. An object does not have state but performs some business arithmetics.

To efficiently use the memory and also to achieve the business calculations, which pattern class is useful?

a) MVC pattern

Page 18: Sample Questions Advance Java-Design Pattern

b) Value object pattern

c) Command pattern

d) Business Object

e) Singleton pattern

65. Your application exposes the entire business service API to its clients across a network.

Which of the following design pattern causes the above situation?

a) Business Delegate

b) Data Access Object

c) Value Object

d) Model View Controller

e) None of the listed options

66. In Java, the Calendar class is an abstract class.

The getInstance() method, for example, instantiate Gregorian Calendar using default time zone and locale.

This closely resembles which of the following Design pattern?

a) MVC Pattern

b) Calendar Pattern

c) Instance Pattern

d) Factory Pattern

e) All of the listed options

67. java.lang.System is a closely resembled example of which of the following pattern?

a) Factory Pattern

b) Singleton Pattern

Page 19: Sample Questions Advance Java-Design Pattern

c) Transfer Object Pattern

d) Business Object Pattern

e) None of the listed options

68. EJBHome defines an interface for creating the EJBObject implementations.

Which of the following is the closely resembled pattern for the above Java implementation?

a) MVC Pattern

b) EJB Pattern

c) HomeCreator Pattern

d) Factory Pattern

e) All of the listed options

69. You can traverse through the elements of many Java Collection objects because they provide a way to access their

elements sequentially.

What design pattern is used here?

a) Visitor

b) Observer

c) MVC

d) Business Delegate

e) Iterator

70. Your client is using J2EE for their Customer Management system. The system uses a combination of HTML and JSP for

presentation. Java Servlets are used as Controllers. All Servlets have access to a ServletContext object, which functions as

a Container to the shared resources of the Servlets.

The ServletContext object best exemplifies what design pattern?

Page 20: Sample Questions Advance Java-Design Pattern

a) Iterator

b) Mediator

c) Interpreter

d) State

e) Singleton

71. When a client calls a remote method, there will be process of marshalling, network calls and unmarshalling involved for

the remote method invocation. If you choose fine grained approach when calling methods remotely, there will be a

significant network overhead involved.

What design pattern will solve this problem?

a) Value Object Pattern

b) Singleton Pattern

c) MVC Pattern

d) Business Object Pattern

e) None of the listed options

72. J2EE applications generally have the search facility and have to search huge data and retrieve results. If an application

returns huge queried data to the client, the client takes long time to retrieve that large data and if that application uses

entity bean to search data, it has an impact on performance.

Which design pattern implementation would reduce this overhead?

a) Facade Pattern

b) MVC Pattern

c) Value List Handler Pattern

d) Business Delegates

e) None of the listed options

Page 21: Sample Questions Advance Java-Design Pattern

73. Your application needs to support customers searching for a list of books based on some information entered in a JSP

page. The matching result set can be quite large.

Which of the following is the best way to return the query results to the client?

a) Invoking the EJB select methods of remote entity beans

b) Implementing a Value List Handler pattern which uses a Data Access Object

c) Implementing a Value List Handler pattern which uses JDBC

d) Using a session facade to get the data from remote entity beans

e) Invoking finder methods of remote entity beans

74. The application's data structure currently maintained by your organization is changed. To avoid impact on the client layer of the application because of the change in data structure, which design pattern is suitable?

a) Value Objects

b) Business Objects

c) Data Access Objects

d) MVC Pattern

e) None of the listed options

75. The application you are developing has a requirement of accessing data in a tabular format (browsing a catalog or list of

names). These data are read only data.

In such situation, which design pattern is best suited?

a) Façade

b) Transfer Objects

c) Business Delegate

d) Fast Lane Reader

e) None of the listed options

Page 22: Sample Questions Advance Java-Design Pattern

76. To meet the requirement of representing the common content and page specific content in an application view, which

pattern is suitable?

a) MVC

b) Business Delegate

c) Front Controller

d) Composite View

e) None of the listed options

77. The Web application you are maintaining is composed of brittle collections of interdependent Web pages. Such

applications can be hard to maintain and extend.

Which pattern will be best suited in this situation?

a) Façade

b) MVC

c) Transfer Object

d) Front Controller

e) None of the listed options

78. Which pattern wraps existing application resources with a filter that intercepts the reception of a request and the

transmission of a response?

a) Front Controller

b) Intercepting Filter

c) MVC

d) Business Delegate

e) None of the listed options

Page 23: Sample Questions Advance Java-Design Pattern

79. Which design pattern best suits for an application to access different databases

a) DAO Pattern

b) MVC Pattern

c) Business Delegate

d) Business Object

e) None of the listed options

80 .You have data stored in a database and clients that need to access it with standard browsers or Wireless appliances such as PDAs.Which of the following pattern would best suit for your application?

a) MVC Pattern

b) Value Object

c) Business Delegate

d) Business Object

e) Data Access Object