1. Home
  2. Training Library
  3. Programming
  4. Programming Courses
  5. Using Design Patterns in Java Projects

Design Pattern Questions

Contents

keyboard_tab
Design Patterns
1
Design Patterns
PREVIEW2m 26s
2
Singleton Pattern
PREVIEW3m 13s
9
Decorator
7m 48s
10
Flyweight
9m 20s
11
Proxy
7m 36s
12
Facade
6m 5s
14
Command
11m 44s
15
Iterator
8m 24s
16
Visitor
9m 4s
17
Mediator
11m 38s
18
Memento
9m 48s
19
Observer
10m 40s
20
Strategy
8m 27s
21
State
10m 27s
22
Template
7m 56s
23
MVC
10m 27s
26
DAO
10m 27s
27

The course is part of this learning path

Start course
Overview
Difficulty
Intermediate
Duration
4h 56m
Students
20
Ratings
5/5
starstarstarstarstar
Description

This course takes an in-depth look at how to use design patterns in your Java projects. We will then run through some example questions of what you could expect from the Oracle Certified Java EE exam.

Learning Objectives

  • Understand what design patterns are
  • Learn about the myriad of design patterns that you can use in your projects

Intended Audience

This course is intended for anyone who already has basic knowledge of Java and now wants to learn about Java EE 6.

Prerequisites

Basic knowledge of Java programming.

 

Transcript

Hello. We have now finished Solid and Design Patterns topic. Now, we will start to solve some questions about this topic to make more practice. Let's begin with the first question. One. The Factory Method design pattern is handy when a client must create objects having different ...?

Fill in the blank in the question; A, ancestors. B, dimensions. C, subclasses. D, similarities. Answer, C. Two, which design pattern in the following options limit the number of instances a class can create? A, limiter. B, strategy. C, singleton. D, command. Answer, C. Three. Iterators are useful when dealing with which of the following types of classes? A, singleton. B, dynamic. C, collection. D, small. Answer, C. Four, what is the pattern that separates the client from concrete application classes? A, Isolator. B, Abstract Factory. C, State. D, Prototype. Answer, B. Five. Which of the following models makes it easier for you to add new types of components? A, Proxy. B, Flyweight. C, Visitor. D, Composite. Answer, D. Six. Which model provides a simple interface to a complex subsystem? A, facade. B, bridge. C, state. D, proxy. Answer, A. 

Seven. Which model allows for different variations of an algorithm? A, memento. B, variation. C, strategy. D, flyweight. Answer, C. Eight. Which of the following patterns can be used to notify an object when another object changes? A, observer. B subscriber. C, publisher. D, memento. Answer, A. Nine. What is also known as the Abstract Factory pattern? A, kit. B, virtual constructor. C, wrapper. D, cursor. Answer, A. 10. Which of the following models can be used when a class cannot predict the class of objects it should create? A, command. B, Abstract Factory. C, factory method. D, chain of responsibility. Answer, C. 11. Which model is also known as virtual constructor? A, memento. B, wrapper. C, Abstract factory. D, factory Method. Answer, D. 12. Which model separates function from implementation? A, proxy. B, bridge. C, observer. D, decorator. Answer, B. 13. What is also known as the adapter model? A, surrogate. B, wrapper. C, token. D, proxy. Answer, B. 14. Which model provides a single interface to simplify many subsystem interfaces? A, proxy. B, adapter. C, facade. D, bridge. Answer, C. 15. Which pattern is also known as the handle body? A, proxy. B, Abstract Factory. C, bridge. D, adapter. Answer, C. 16. Which model reduces coupling and allows a set of classes to behave like one? A, chain of responsibility. B, command. C, Memento. D, factory method. Answer, A. 17. What is also known as the decorator pattern? A, wrapper. B, adapter. C, composite. D, strategy. Answer, A. 18. Which pattern code is a common technique for reuse? A, template method. B, command. C, Singleton. D, state. Answer, A. 19. Which pattern is also known as Surrogate? A, proxy. B, observer. C, bridge. D, decorator. Answer, A. 

20. What is also known as the command pattern? A, action. B, transaction. C, wrapper. D, surrogate. Answer, A, B. 21. The command design pattern ...... a request in an object. Fill in the blank in the question. A, separates. B, decouples. C, encapsulates. D, processes. Answer, C. 22. Which of the following options is an element of the Gang of Four (GoF) Design Pattern format? A, problem. B, solution. C, consequence. D, intent. Answer, C, D. 23. Which of the following aspects can prevent the Thread Tracker model from working? A, Java specification. B, target environment. C, logging tool in use. D, interceptor annotation. Answer, B. 24. Which of the following requirements is suitable for the singleton model? A, establishing a load order for servlets. B, implementing a per JVM instance. C, implementing a per server instance. D, A and B. E, B and C. Answer, B. 25. To create a suitable payload extractor you must guarantee? A, transactions cannot be undone. B, consume messages will be forwarded. C, the load is not large. D, the message type is valid. Answer, B. 26. Which annotation defines a prerequisite class for the annotated class? A, @Attach. B, @DependsOn. C. @Inject. D, @Depends. Answer, B. 27. The service and gateway patterns are; A, interchangeable. B, least popular. C, fungible. D, direct opposites. Answer, D. 28. Which model ensures that a session bean is executed at deployment time? A, service starter. B, resource binder. C, context holder. D, singleton. Answer, A. 

29. Which of the following can include JNDI services and provide them for non-Java EE clients? EE clients. A. Resource binder. B. Singleton. C. Bean locator. D. Persistent domain object. Answer, C. 30. Which of the following patterns can be used to save custom resources to the application server. A. Resource binder. B. Bean locator. C. Persistent domain object. D. Singleton. Answer, A. 31. Which of the following models would you choose to allow spring components to participate in the transaction and security context of an EJB? A. Context holder. B. Dependency injection extender. C. Thread tracker. D. Gateway. Answer, B. 32. Which of the following models is used to validate an asynchronous message payload to avoid the hot potato anti pattern? A. Payload extractor. B. Asynchronous resource integrator. C. Context holder. D. Resource binder. Answer, A. 33. Which of the following patterns is used to share data portably between participants in a transaction? A. Persistent domain object. B. Data transfer object. C. Context Holder. D. Gateway. Answer, C. 34. Which of the following patterns makes it easy to define functions and instances for a service thread in a log file? A. Log4J. B. Context holder. C. Thread tracker. D. Resource binder. Answer, C. 35. Which of the following options most accurately summarizes the Law of Leaky Abstractions? A. Code that relies entirely on complex abstract interfaces can be anti pattern. B. All abstractions are anemic and leaky. C. The software will fail in the long run. D. This is the only reason for anti patterns. Answer, A. 

36. What option makes it difficult to identify the hot potato anti pattern? A. The server is located outside of an air conditioned environment. B, Queues transmit one message at a time. C. Message oriented kernels are not easily debugged. D. The message server is remote. Answer, B. 37. What anti pattern defines the scenario where the business logic is applied separately from the domain objects or data on which it runs? A. Fat object. B. Monolithic consumer. C. Hot potato. D. Anemic domain model. Answer, D. 38. Which of the following options is the anti pattern that describes the observed slow performance scenario for a method in a component that connects to a database performs a query and then disconnects from the database? A. Anemic query model. B. Inadequate covering key. C. Missing index. D. Not pulling connections. Answer, D. 39. What anti pattern might exist in the case where you have highly static resources that are called and used over and over again? A. Cacheless cow. B. Time to live. C. Sledgehammer for a fly. D. Bazooka for a fly. Answer, A. 40. What option would potentially anti pattern arise if an EJB component is used instead of Pugio for all business logic regardless of complexity? A. Sledgehammer for a fly. B. Monolithic consumer. C. Conversational baggage. D. Bazooka for a fly. Answer, A. 41. What anti pattern is there when all jsp pages have URL and file references? A. Including common functionality. B. Conversational baggage. C. Embedded navigational information. D. Ad Lib Taglibs. Answer C.

 

About the Author
Students
413
Courses
35
Learning Paths
2

OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.

Covered Topics