Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The \"extends\" part of a use-case diagram represents: a) Exceptional cases b) I

ID: 2247092 • Letter: T

Question


The "extends" part of a use-case diagram represents: a) Exceptional cases b) Inherited functionality c) Additional steps required d) None of the above Look at the code below. What design pattern is suggested by this code? a) Factory b) Decorator c) Singleton d) Observer e) Adapter public class Smartphone { List sensors = new ArrayList (): public void registerEvents (Sensor s) { sensors.add(s): } public void notifyEvent (Event e) { for (Sensor s: sensors) { s.notifyEvent(e): } } } Which design pattern is structural? a) Factory b) Adapter c) Singleton d) Decorator e) Observer Which design pattern is creational? a) Factory b) Adapter c) Singleton d) Decorator e) Observer To prevent others from inheriting from your class, you should a) Declare the class static b) Make it an abstract class c) Declare the class final d) Declare a private constructor e) None of the above

Explanation / Answer

25)Answer: Exceptional cases

Explanation:

Extend Relationship:

In this relationship, an extension use case is created to extend the behavior of the extended (base) use case when exceptional circumstances are encountered. An extend relationship is used to represent an optional or exceptional behavior.

27)Answer: Adapter

Explanation:

Adapter pattern works as a bridge between two incompatible interfaces. This type of design pattern comes under structural pattern as this pattern combines the capability of two independent interfaces.

This pattern involves a single class which is responsible to join functionalities of independent or incompatible interfaces. A real life example could be a case of card reader which acts as an adapter between memory card and a laptop. You plugin the memory card into card reader and card reader into the laptop so that memory card can be read via laptop.

28)Answer: Factory method,singleton

Explanation:

Factory method:

Factory method is a creational design pattern, i.e., related to object creation. In Factory pattern, we create object without exposing the creation logic to client and the client use the same common interface to create new type of object.

Singleton:

Singleton pattern, which ensures that a class only has one instance, and provides a global point of access to it

29)Answer: Declare the class final

Explanation:

To stop a class from being extended, the class declaration must explicitly say it cannot be inherited.

This is achieved by using the "final" keyword:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote