a presentation tier component is requesting data attributes

Upload: prince-jain

Post on 09-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    1/24

    A presentation tier component is requesting data attributes, which are scattered in multiple

    business components, DAOs and services in your application?

    Which pattern is best suited for this scenario, providing the client with the required data causingno significant performance degradation?

    No. Answers Correct You selected

    1 Business Object

    2 Transfer Object Assembler

    3 Data Acess Object4 Composite Entitiy

    When is it recommended to use a Value List Handler Pattern?

    No. Answers CorrectYou

    selected

    1 You want to avoid embedding business logic in the view

    2You want to avoid passing protocol-specific information outside its

    context

    3

    You want to provide the clients with an efficient search and iterate

    mechanism over a large results set

    4 You want to maintain the search results on the client side

    Your online shop application maintains the customers information, like their personal

    information,contact lists and lists of purchases.

    The remote descktop clients usually require only parts of these information. Which pattern

    would be most appropriate for this scenario and would improve your system?

    No. Answers Correct You selected

    1 Updatable Transfer Objects

    2 Transfer Object Assembler3 Entity Inherits Transfer Object

    4 Multiple Transfer Objects Strategy

    You application's performance is affected due to repeated JNDI lookups done by every clientaccessing your application.

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    2/24

    Which pattern is most appropriate to improve the performance and solve the problem?

    No. Answers Correct You selected

    1 Service Locator 2 Session Facade3 Business Delegate

    4 Transfer Object

    A service locator is best implemented as a Singleton.

    No. Answers Correct You selected

    1 true

    2 false

    Your application's performance is affected due to the significant number of remote calls to your

    business logic. The business logic is exposed as fine grained methods to the clients.

    Which refactoring can be done to improve the application's performance? (choose two)

    (choose 2)

    No. Answers CorrectYou

    selected

    1 Add a Front Controller to centralize requests processing

    2

    Implement a Session Facade, which provides a coarse grainedservice-oriented interface

    to clients

    3 Move the frequently called business logic to the presentation tier

    4

    Encapsulate multiple business data attributes into smaller set of

    serializable transfer objects, to reduce remote invocations

    ABC university library system is available to students over different campuses in the world and

    installed in one server in the main campus. Queries results are usually large result sets returned

    all to clients which causes a heavy load on both client and server.

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    3/24

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    4/24

    Which integration pattern can be used to integrate Java EE code to a relational database?

    No. Answers Correct You selected

    1 Service Activator

    2 Front Controller

    3 Data Access Object (DAO)4 Web Service Broker

    What pattern is applied in Java Message Driven Beans?

    No. Answers Correct You selected

    1 Service Locator

    2 Service Activator 3 Service to Worker

    4 Front Controller

    You want to expose part of your application as services to other client applications. The clientapplication will request a service through standard web protocols. The requests are received by a

    servlet which in turn delegetes them to the bussiness tier.

    Which pattern is most appropriate for this task?

    No. Answers Correct You selected

    1 Service Activator

    2 Service Locator

    3 Web Service Broker

    4 Service to Worker

    What is the role of a Service Activator?

    No. Answers CorrectYou

    selected

    1 A Service Activator acts as a centralized point to process http

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    5/24

    No. Answers CorrectYou

    selected

    requests

    2

    A Service Activator allows an asynchronous messages to invoke

    business components, including the EJBs3

    A Service Activator enables business logic in EJBs to be exposed

    as web services

    What benefits does Data Access Object (DAO) pattern provide? (choose two) (choose 2)

    No. Answers CorrectYou

    selected

    1it increases the cohesiveness of the business objects by extracting

    out the data acess code from them

    2 it reduces network overhead by caching queries results3

    it enhances loose coupling between the business tier and the data

    sources

    Presentation Tier----------------

    How to secure you web application against security risks such as cross site scripting (css) and

    SQL injection in a centralized manner that avoids code duplicate and ensures that every HTTPrequest would be inspected? (choose 2)

    No. Answers Correct You selected

    1 use Intercepting Filter pattern

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    6/24

    No. Answers Correct You selected

    2 use Front Controller pattern

    3 use Composite View pattern4 use Business Delegate pattern

    Which of the following patterns would you use to transfer certain state to the next tier without

    passing on protocol-specific system information?

    No. Answers Correct You selected

    1 Transfer Object2 Context Object

    3 Context Filter

    4 Service To Worker

    Your job is to refactor an application ,which uses JSP technology as a View. The JSP pages are

    dominated by scriptlet code.

    Which pattern would be appropriate to solve this problem?

    No. Answers Correct You selected

    1 View Helper

    2 Composite View3 Data Access Object

    4 Context Object

    In your web application you decided to use Javascript to validate each user input on the client

    browser.

    Where do you need to duplicate the validation code on the server?

    No. Answers CorrectYou

    selected

    1No double check on the server side is needed as the input is already

    checked on the client side

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    7/24

    No. Answers CorrectYou

    selected

    2 double check in the presentation tier3 double check in the integration tier

    4 double check in the business tier

    Explanation:

    You always need to double check the user input as it not guaranteed that user is actually usingthe intended interface as you planned.

    You would like to raise the security level of your system by examining incoming HTTP

    requests. You would like to log information about each request and to filter requests withmalicious scripts.

    Where would you put such request processing code?

    No. Answers Correct You selected

    1 in the Service Locator

    2 in the Service Activator

    3 in the Intercepting Filter

    4 in the View Helper

    Your Parcel delivery company is expanding it's existing web application.

    Currently the clients can track their parcels using web browsers, and your company wants to

    expose it's business to it's partners as web-services.

    However; when you inspected the code base, you discovered that the application passes

    HttpServletRequest parameters to the business tier for further processing.

    Your job is to refactor this existing code base to avoid duplicating the business logic to handle

    the two request channels (http and web service requests).

    Which refactoring is appropriate for this case without code duplication?

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    8/24

    No. Answers Correct You selected

    1 Use front controller pattern

    2 Use context object pattern3 Use proxy pattern

    4 Use service broker pattern

    you are in charge of developing an e-commerce web application, the client expects high trafficvolumes and the security is of essence.

    Which user session management strategy would you choose?

    No. Answers Correct You selected

    1 Save user session in http cookies

    2 Save user session in html hidden fields3 Save user session in an HttpSession object

    4 Save user session in an EJB stateful session bean object

    A pattern that is intended to provide a means to define a family of algorithms and encapsulate

    each one as an object for interchangeable use:

    No. Answers Correct You selected

    1 Strategy Pattern

    2 Abstract Factory Pattern

    3 Visitor Pattern4 State Pattern

    It is known as Action or Transaction and is used to encapsulate a request as an object to support

    rollback, logging, or transaction functionality

    No. Answers Correct You selected

    1 Chain of Responsibility Pattern2 Command Pattern

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    9/24

    No. Answers Correct You selected

    3 Observer Pattern

    4 Strategy Pattern

    Which is considered an example of Chain of Responsibility Pattern? (choose two) (choose 2)

    No. Answers Correct You selected

    1 java.awt.event.ComponentAdapter

    2 The Java Servlet filter framework

    3 javax.jms.QueueConnectionFactory4 java.awt.Toolkit

    5 Java exception handling

    Which are considered forces to select a Strategy Pattern? (choose two) (choose 2)

    No. Answers Correct You selected

    1 A client needs to use a family of related objects2 A change to an object requires changing other objects

    3 A client needs to choose from multiple algorithms

    4 Multiple classes are the same but differ only in their behaviors

    java.util.Enumeration is an example of which pattern?

    No. Answers Correct You selected

    1 Iterator

    2 Command

    3 Observer 4 Strategy

    In the Publish-Subscribe messaging model, the subscribers register themselves in a topic and are

    notified when new messages arrive to the topic. Which pattern does most describe this model?

    No. Answers Correct You selected

    1 Adapter 2 Notifier

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    10/24

    No. Answers Correct You selected

    3 Observer

    4 StateExplanation:

    The Observer pattern is used to define a one-to-many dependency so that when one objectchanges state, all its dependents are notified and updated automatically.

    This definition is perfectly describe Publish-Subscribe model, actually the Observer pattern isalso known as Publish-Subscribe.

    Which pattern to use when more than one object can handle a request, and the handler isunknown?

    No. Answers Correct You selected

    1 Chain of Responsibility

    2 Command3 Strategy

    4 Observer

    Which pattern is most appropriate when a decision must be made at the time a class is

    instantiated?

    No. Answers Correct You selected

    1 Bridge

    2 Composite

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    11/24

    No. Answers Correct You selected

    3 Factory Method

    4 CommandExplanation:

    Creational Design Patterns are used when a decision must be made at the time a class isinstantiated.

    GoF Creational Design Patterns are :

    1. Abstract Factory

    2. Builder

    3. Factory Method

    4. Prototype

    5. Singleton

    Which design pattern is used in the Java Database connectivity JDBC(TM)?

    No. Answers Correct You selected

    1 Builder design pattern

    2 Factory method design pattern3 Abstract Factory design Pattern

    4 Singletone design Pattern

    Which GOF design pattern is applied in the code snippet below?view source

    print?01.publicclassPrintSpooler {

    02.03.privatestaticfinalPrintSpooler INSTANCE = newPrintSpooler();

    04.05.privatePrintSpooler() {}

    06.07.publicstaticPrintSpooler getInstance() {

    08.09.returnINSTANCE;

    10.

    http://www.javachamp.com/public/showQuestionDetail.xhtml?itemIndex=2&examId=400738#viewSourcehttp://www.javachamp.com/public/showQuestionDetail.xhtml?itemIndex=2&examId=400738#printSourcehttp://www.javachamp.com/public/showQuestionDetail.xhtml?itemIndex=2&examId=400738#abouthttp://www.javachamp.com/public/showQuestionDetail.xhtml?itemIndex=2&examId=400738#viewSourcehttp://www.javachamp.com/public/showQuestionDetail.xhtml?itemIndex=2&examId=400738#printSourcehttp://www.javachamp.com/public/showQuestionDetail.xhtml?itemIndex=2&examId=400738#about
  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    12/24

    11.}

    12.13.}

    No. Answers Correct You selected

    1 PrintSpooler design pattern2 Spooler design pattern

    3 Singleton design pattern

    4 Factory design pattern5 Abstract Singleton design pattern

    Which of the following are participants in the GOF builder design pattern? (choose 3)

    No. Answers Correct You selected

    1 Builder interface2 Constructor Interface3 Director Interface

    4 Concrete Builder class

    5 Concrete constructor class

    When would you use the GOF Singleton design pattern? (choose all that apply) (choose 2)

    No. Answers CorrectYou selected

    1 to ensure that a certain group of related objects are used together2 to limit the class instantiation to one object

    3 to provide global access to once instance across the system4 to abstract steps of construction of complex objects

    Which design pattern you would you use to limit the class instantiation to one object?

    No. Answers Correct You selected

    1 Factory Method Design Pattern

    2 Builder design pattern3 Prototype design pattern

    4 Singleton design pattern

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    13/24

    What are the consequences of applying the abstract factory patter? (choose 2)

    No. Answers Correct You selected

    1 it will be much easier to introduce new family of products

    2 it makes it easier for a certain family of objects to work together

    3 it makes it easier for the client to deal with tree-structured data4 it makes the designed product families exchangeable

    When would you use the GOF builder design pattern? (choose all that apply) (choose 2)

    No. Answers CorrectYou

    selected

    1 to abstract steps of construction of complex objects

    2to build different representations of complex objects based on the

    concrete implementations of construction procedure

    3to establish an interface for creating an object, but let the concrete

    implementations decide which subclass to instantiate

    4to encapsulate a family of individual factories that have a common

    theme

    Given the following scenario:

    You want to create families of related objects, to be used interchangeably to configure you

    application. What is the most appropriate GoF pattern to use?

    No. Answers Correct You selected

    1 Chain of Responsibility2 Abstract Factory

    3 Builder

    4 Observer

    Which design pattern you would you use to control the creation of an object based on a

    established interface, while allowing the concrete implementation to determine the subclass to

    construct.

    No. Answers Correct You selected

    1 Singleton design pattern

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    14/24

    No. Answers Correct You selected

    2 Builder Factory design pattern

    3 Prototype factory design pattern4 Factory method design pattern

    What are the consequences of applying the Builder design pattern? (choose 3)

    No. Answers Correct You selected

    1 it makes the designed product hierarchies exchangeable

    2 it's easier to introduce new product implementation3 it separates the prodcut construction from it's representation

    4 the director has fine control over the product creation procedure

    What are the consequences of applying the GOF Singleton pattern? (choose 1)

    No. Answers CorrectYou

    selected

    1it introduces thread safety issue when the singleton instance is

    instantiated on demand

    2 the client code can creates multiple instances at run time

    3

    it reduces of the class hierarchy as compared to the other factory

    design patterns4 it makes it easier for a certain family of objects to work together

    Which design pattern you would you use to have a prototypical instance determine the concrete

    class of object being created?

    No. Answers Correct You selected

    1 Prototype factory design pattern

    2 Virtual prototype design pattern3 Abstract prototype design pattern

    4 Prototype design pattern

    Which of the following code snippet represents a Singleton design pattern implementation?

    No. Answers CorrectYou selected

    1 public class PrintSpooler {

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    15/24

    No. Answers CorrectYou selected

    public PrintSpooler INSTANCE = new PrintSpooler();

    public PrintSpooler () {}

    public static PrintSpooler getInstance() {

    return INSTANCE;

    }

    }

    2

    public class PrintSpooler {

    private PrintSpooler INSTANCE = new PrintSpooler();

    private PrintSpooler () {}

    public static PrintSpooler getInstance() {

    return INSTANCE;

    }

    }

    3

    public class PrintSpooler {

    private static final PrintSpooler INSTANCE = new PrintSpooler();

    private PrintSpooler () {}

    public static PrintSpooler getInstance() {

    return INSTANCE;

    }

    }4 public class PrintSpooler {

    private final PrintSpooler INSTANCE = new PrintSpooler();

    private PrintSpooler () {}

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    16/24

    No. Answers CorrectYou selected

    public static PrintSpooler getInstance() {

    return INSTANCE;

    }

    }

    What are the consequences of applying the GOF Prototype pattern? (choose 3)

    No. Answers CorrectYou

    selected

    1 each concrete prototype class must implement the clone method

    2 it makes it easier for a certain family of objects to work together

    3it enable the client code to register an new concrete prototype

    instance at run time

    4it reduces of the class hierarchy as compared to the other factorydesign patterns

    What are the consequences of applying the GOF factory method pattern? (choose 2)

    No. Answers CorrectYou

    selected

    1 it decouples the client code from the application specific classes2 it makes the designed product families exchangeable

    3it establishes a flexible mechanism for instantiating an object in

    comparison to the usual java constructor instantiation.

    What are the consequences of applying the GOF Composite pattern? (choose 2)

    No. Answers CorrectYou

    selected

    1 the client code can traverse tree structures of arbitrary depth

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    17/24

    No. Answers CorrectYou

    selected

    recursively

    2increases the coupling between the client code and the composite

    structre

    3 it will improve the system performance4

    the client code can access both the individual objects and

    compositions in a uniform manner

    A pattern known as Surrogate is :

    No. Answers Correct You selected

    1 Adapter 2 Proxy

    3 Facade4 Method Factory

    What are the consequences of applying the GOF Decorator pattern? (choose 3)

    No. Answers CorrectYou

    selected

    1the client code can gradually add more functionality as it nests more

    layers of decorators2 it assigns more functionality to an object without sub-classing it

    3it makes it harder to identify the the decorated and the decorator

    objects

    4the client code can traverse tree structures of arbitrary depth

    recursively

    You are trying to add a class already written in another application to serve clients, beside other

    classes, in your system. All other classes have the same interface, the incoming class has a

    totally different interface than the clients expect, but contains all required functionalities.

    What kind of refactoring is needed to make this class fit in with minimum changes in your

    system?

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    18/24

    No. Answers CorrectYou

    selected

    1 apply the Proxy Pattern2 apply the Adapter Pattern

    3

    create a new class which implements the expected interface and

    copy and paste

    the code from the class in the other application to this new classExplanation:

    The Adapter pattern converts the interface of a class into an interface that a client expects.

    Which design pattern is used in the Java InputStream, OutputStream, Reader, Writer hierarchies?

    No. Answers Correct You selected

    1 Adapter design pattern

    2 Decorator design pattern3 Composite design pattern

    4 Bridge design pattern

    Which design pattern is used in the Java AWT Abstract Window Toolkit?

    No. Answers Correct You selected

    1 Adapter design pattern

    2 Composite design pattern

    3 Bridge design pattern4 Proxy design pattern

    What is the difference between an adapter and a decorator? (choose two) (choose 2)

    No. Answers CorrectYou

    selected

    1

    The adapter adds no functionalities to the adaptee class, whereas the

    Decorator

    extends the functionality of the object

    2The adapter is a creational pattern, whereas the decorator is a

    structural design pattern

    3Both introduce a level of indirection between a client class and a

    class it uses

    Explanation:

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    19/24

    Both the adapter and the decorator are structural design patterns

    Big portion of clients are remotely invoking methods in your system, the surface area exposedto clients includes fine-grained methods, which of course causes network overhead.

    Which pattern would improve your system performance in this case?

    No. Answers Correct You selected

    1 Chain of Responsibility Pattern

    2 Facade Pattern

    3 Command Pattern

    4 Adapter PatternExplanation:

    Facade pattern provides a simpler interface to a complex subsystem. This way a coarse-grained

    methods are available to clients instead of fine-grained ones, this way the network overhead isreduced, thus performance if improved.

    You are building an online makeup website, which provides beside text articles, makeup

    tutorials as videos files.

    Which pattern is recommended to use in such a website to deliver these media resources?

    No. Answers Correct You selected

    1 value list handler 2 virtual proxy

    3 intercepting filter 4 composite view

    Which design pattern you would you use to decouple an abstraction from its implementation so

    that the two can vary independently?

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    20/24

    No. Answers Correct You selected

    1 Adapter design pattern

    2 bridge design pattern3 Facade design pattern

    4 Composite bridge design pattern

    Which design pattern you would you use to translates an existing class interface into acompatible target interface?

    No. Answers Correct You selected

    1 Proxy design pattern

    2 Adapter design pattern

    3 Facade design pattern4 Adapter factory design pattern

    Which design pattern you would you use to assign more functionality to an object without sub-classing it?

    No. Answers Correct You selected

    1 Bridge design pattern2 Adapter design pattern

    3 Composite design pattern

    4 Decorator design pattern

    It is also known as Wrapper, it is used when subclassing is not possible or practical to add

    functionality and it is used to add functionality at runtime. This pattern is :

    No. Answers Correct You selected

    1 Composite

    2 Adapter 3 Decorator

    4 Proxy

    A Proxy Pattern is best used to : (choose three) (choose 3)

    No. Answers CorrectYou

    selected

    1 control access to a remote object

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    21/24

    No. Answers CorrectYou

    selected

    2 assemble complex objects3 fetch a resource-intensive object when requested by a client

    4 store common redundant data between large number of objects

    5 extract out from the calling client the access or connection logicneeded to call an object

    Which of the following is a Gang of Four (GoF) Structural Design Pattern? (choose 2)

    No. Answers Correct You selected

    1 Composite

    2 Flyweight3 Singleton

    4 Method FactoryExplanation:

    Composite and Flyweight are Gang of Four (GoF) Structural Design Patterns, whereas Singletonand Method Factory are Creational Design Patterns

    When would you use the GOF Adapter design pattern? (choose all that apply) (choose 3)

    No. Answers CorrectYou

    selected

    1to translates an existing class interface into a compatible targetinterface

    2 to improve your system performance

    3to transforming the client code data into appropriate format

    expected by the target interface4 to allow classes with incompatible interfaces to work together

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    22/24

    In EJB 2.x, the client can directly access the session bean by invoking their business methods:

    No. Answers Correct You selected

    1 true

    2 false

    Explanation:

    Clients cannot access session beans directly. To gain access to

    session bean methods, they use instances of EJBObject . Therefore any method, in the session

    bean, designated to be available to clients, must be added to the EJBObject of the bean.

    Message Driven Beans (MDBs) can be pooled by the EJB container.

    No. Answers Correct You selected

    1 true2 false

    Explanation:

    Like the stateless session beans and the entity beans, message driven beans can be pooled by the

    EJB container

    What services EJB containers provide to Session beans? (choose 3)

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    23/24

    No. Answers Correct You selected

    1 Caching and pooling

    2 EJB life cycle management3 HTTP requests management

    4 RMI services

    What is the default transaction attribute to a method in an EJB? (no explicit transaction attributeis declared in both class and method levels)

    No. Answers Correct You selected

    1 NotSupported

    2 Required

    3 Supports4 Mandatory

    5 Never

    What is the typical order of life cycle stages an average stateless session bean goes throughstarting from its instantiation till retiring?

    No. Answers CorrectYou

    selected

    1Instantiation by the EJB container, PostConstruct call back,

    Dependency injection, PrePassivate

    2Instantiation by the EJB container, PostConstruct call back,

    Dependency injection, PreDestroy

    3Instantiation by the client code, Dependency injection,PostConstruct call back, PreDestroy

    4Instantiation by the EJB container, Dependency injection,

    PostConstruct call back, PreDestroy

    Which of the following transactional settings would throw an exception when calling a method

    while the presence of an already existing transaction context?

    No. Answers Correct You selected

    1 NotSupported

    2 Required

    3 Supports4 RequiresNew

    5 Mandatory

  • 8/8/2019 A Presentation Tier Component is Requesting Data Attributes

    24/24