Quiz
Software Design Patterns
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (19)
1The original creators of design patterns were known as the gang of four. How many design patterns are there?
- A40
- B25
- C23
- D32
2Design patterns are about reusing and the design experience. How is the design pattern expressed?
- AIt is expressed by algorithms, an object class, and collected into mathematic operators.
- BIt is expressed by a definition, a class diagram, and collected into a catalog of patterns.
- CIt is expressed by agile methodology, testing, and release history.
- DIt is expressed by common problems you create from risk analysis.
3Design patterns are comprised of object-oriented basics. What are the object-oriented basics?
- AThe basics are experience, algorithm, abstraction, and encapsulation.
- BThe basics are state, behavior, classes, and interfaces.
- CThe basics are inheritance, polymorphism, abstraction, and encapsulation.
4An object is an instance of a class. What is a concrete instance when working with design patterns?
- AA concrete instance refers to any occurrence of objects that exist during the runtime of a computer program.
- BA concrete instance refers to dynamic object values that are always changing.
- CA concrete instance refers to the behavior or state of an object.
5Which coding format "implements" when deriving a superclass with a subclass?
- Apublic class SomeSuperClass implements SomeSubClass {
public void doSomething() {
System.out.println("Using implements to derive classes");
}
} - Bpublic class SomeSubClass implements SomeSuperClass {
public void doSomething() { System.out.println("Using implements to derive classes");
}
} - Cpublic class SomeSuperClass implements {
public void doSomething() {
System.out.println("Using implements to derive classes");
}
}
- Apublic class SomeSuperClass implements SomeSubClass {
6Design patterns use algorithms for the strategy pattern. How is the strategy pattern defined?
- AThe strategy pattern defines functional math operations.
- BThe strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable.
- CThe strategy pattern defines one instance of a class with algorithms. It is also called a singleton.
7Which difference does the HAS-A relationship have in comparison to the IS-A relationship?
- AInstead of inheriting behavior like the IS-A relationship, the HAS-A composes the behavior.
- BThe IS-A relationship cannot be inherited, but the HAS-A relationship is inherited.
- CThe HAS-A relationship owns its behavior, whereas the IS-A relationship leases its behavior.
8When working with inheritance, which kind of relationship do you have with classes?
- AClasses share an HAS-A relationship.
- BClasses share a many-to-one relationship.
- CClasses share an IS-A relationship.
9What does abstract mean in inheritance when working with subclasses?
- ASubclasses must add private methods and variables to the superclass.
- BSubclasses must create abstract methods and behaviors because they are abstract.
- CSubclasses must override all abstract methods of its abstract superclass.
10What is an interface, and how is it used in design patterns?
- ADesign patterns use interfaces to create algorithms and math operations.
- BDesign patterns use interfaces to create one instance of a class.
- CDesign patterns use interfaces to define methods an object must have to be considered a particular type.
11When working with design principles, which of the following defines "Encapsulate What Varies"?
- AOnce you separate the parts that are changing, you can then modify those parts without affecting the rest of the code.
- BIt means that your design will change consistently, making your code static and not dynamatic.
- CIt means that you must find a design pattern that works with change.
12The Adapter pattern is a software design pattern. Which coding format is correct for creating the Adapter pattern?
- Aclass BirdAdapter implements ToyDuck
{
Bird bird;
public BirdAdapter(Bird bird)
{
this.bird = bird;
}
} - Bclass ToyDuck implements BirdAdapter
{
Bird bird;
public BirdAdapter(Bird bird)
{
this.bird = bird;
}
} - Cclass BirdAdapter implements Bird
{
Bird bird;
public BirdAdapter(Bird bird)
{
this.bird = bird;
}
}
- Aclass BirdAdapter implements ToyDuck
13Design patterns use the Adapter pattern to solve problems with different interface problems. Which action does the Adapter pattern take?
- AThe Adapter pattern handles the implementation of difficult designs into the source code.
- BThe Adapter pattern handles the work of translating the request to a new class.
- CThe Adapter pattern handles different data types into an international type for all classes.
14The Observer pattern has design principles of loose coupling. Describe the term "loose coupling."
- ALoosely coupled means routines are called by an application and executed as needed
- BLoosely coupled means the design can be dynamic, with other design patterns with no logic.
- CLoosely coupled means designs can be integrated into many different patterns.
15The Observer pattern has two components; they are the subscriber and the publisher. Which type of relationship exists with the subscriber and publisher?
- APublishers send messages, and subscribers receive the messages.
- BIt is a one-to-many relationship. There is one publisher to many subscribers.
- CPublishers post messages to a message broker, and subscribers register subscriptions to the message broker.
16The Observer pattern uses the Subject interface. Which three methods comprise the Subject interface?
- ASend method, Receive method, and Register method
- BRegisterObserver method, RemoveObserver method, and NotifyObserver method
- CCreate method, Subscribe method, and Update method
17Why are the subjects and observers in the Observer pattern considered "loosely coupled"?
- ABecause they do not know a lot about each other, they are independent.
- BBecause they are in configuration files; they are not coded.
- CBecause they are considered subclasses and need the superclass for any interaction.
18In Design Patterns, we favor composition over inheritance. Why is this beneficial?
- AWe can use the step-by-step process that composition gives us.
- BWe can use composition to get the flexibility, without all the complexity that inheritance gives us.
- CInheritance is difficult to code and harder to debug in a java.
19Why is the "open-closed principle" so important in the Decorator pattern?
- AThe open-closed principle explains that classes should be open for extension, but closed for modification.
- BThe open-closed principle explains that classes should have case statements that switch open and closed.
- CThe open-closed principle means that classes can be switched by a trigger to open or closed classes.
Information
- Description
- Software Development Computer Science Quiz on Software Design Patterns, created by Dustin White on 15/12/2021.
- Author
- Dustin White
- Language
- English
- Views
- 0
- Tags
- Rating
- No ratings yet Rate this quiz