Chapter 19

Questions for Chapter 18

1. Which symbol is used to start a UML 2.5 State Machine Diagram?

image

A. a

B. b

C. c

D. d

E. e

F. f

2. Examine the State Machine Diagram fragment below. What state will the State Machine be in after the events e1, e2, e3, and e1 occur (in that order)?

image

A. It is not possible to tell.

B. S1

C. S2

D. S3

E. The diagram is not a valid State Machine Diagram.

3. Which list completely identifies the possible features of a transition?

A. trigger

B. trigger, guard

C. trigger, guard, state

D. trigger, guard, state, effect

E. trigger, constraint, effect

F. trigger, guard, effect

G. trigger, guard, effect, return

4. What type of behavior should a system exhibit to be most appropriate for using a State Machine to help in understanding the manifest behavior of the system?

A. Continuous and self-adjusting behavior

B. Cooperating identical peer instances

C. Genetic Evolving Algorithms with feedback

D. Discrete Event-driven behavior

E. Time-based Schedule driven behavior

5. Which statement best describes how a higher priority event interrupts the processing of a lower priority event in a UML state machine?

A. The events are taken from the event pool in strict priority order. Thus, a newly arriving high priority event can interrupt ongoing behavior.

B. There is no possibility for interrupting events because of Run-to-Completion Paradigm (RTC).

C. The UML 2.5 Specification does not allow for State Machine-mediated interrupts. However, changes to the priority of an object’s thread and changes to the resources available to the thread may cause a particular thread to be suspended and others to be enabled.

D. Higher priority events may be taken before lower priority events by an unspecified algorithm, causing effective interrupts.

E. The UML 2.5 Specification indicates that completion events are of higher priority than other events. This ordering causes completion events to be examined before external events, leaving interrupts in their wake.

6. A State Machine Diagram has at least one Final State at the top level (at the State Machine diagram level), with more than one incoming edge. When does the State Machine finish?

A. The State Machine finishes when all the incoming edges to the Final State have supplied at least one token.

B. The State Machine finishes with the first transition to a top-level (diagram) Final State.

C. The State Machine finishes when the majority of incoming edges have transitioned to a top-level Final State.

D. The State Machine finishes when every top-level (diagram level) Final State has had a transition into it.

7. In a UML 2.5 State Machine, an expression may be surrounded by square brackets, [ ]. What does this mean?

A. An “invariant constraint” is surrounded by square brackets. The modelers state their intention that the model will enforce these constraint expressions to be true.

B. The use of square brackets announces that the expression is an “opaque expression”, whose meaning is context dependent.

C. Such expressions are “guard conditions” or “guard expressions”, that only allow passage when the contained condition is evaluated to be “true”.

D. The string inside the square brackets identifies a “behavior effect” that invokes an action by the same name on the state machines’ object.

E. The square brackets highlight an error in the original state machine. It is related to the use of Latin, sic (so, thus) to flag errors in the original material in the text.

8. In UML 2.5, when might it be useful to use an exit action in a state machine?

A. An exit action might be useful when all of the possible ways of leaving a state must execute a common behavior or sequence of behaviors.

B. Upon leaving an exit state.

C. Upon entering a final state.

D. An exit action might be useful when most of the possible ways of leaving a state execute a common behavior or sequence of behaviors. The behavior may be an opaque behavior if necessary.

E. There is no such thing as an exit action in UML 2.5 State Machines. It indicates an exit condition.

9. What symbol is used to indicate that substates have been elided?

image

A. a

B. b

C. c

D. d

E. e

10. After this state machine completes, what is the value of X?

image

A. 11

B. 10

C. The state machine never ends

D. 17

E. 20

F. 19

11. Which of the following statements is true about UML State Machines?

A. Every State must have possible transitions in and possible transitions out.

B. Every State Machine diagram must have a final state.

C. The star-shaped state indicates concurrency.

D. Every transition is from one state to another different state.

E. A completion transition is triggered by the completion of the activity within its state.

12. Given the following State Machine fragment for an object of Class X, what is the minimum number of behaviors that have to be implemented inside Class X for the diagram to be correct?

image

A. 0

B. 5

C. 6

D. 7

E. 8

13. In the STM diagram fragment below, we see five transitions marked with italic letters. Which one can’t have a guard condition added?

image

A. a

B. b

C. c

D. d

E. e

14. Assume the below state machine fragment is in State S1.1 when the do activity b4 finishes. What is the sequence of behaviors that then follows?

image

A. b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11

B. The diagram is malformed.

C. b5, b2, b7, b9

D. b5, b2, b7, b9, b10

E. b2, b5, b6, b7, b9, b10

F. b5, b2, b6, b7, b9, b10

15. Examine the following diagram fragment. What statement properly describes the fragment?

image

A. A valid state diagram

B. An invalid activity diagram

C. A valid but not executable activity diagram

D. Both a valid state or an activity diagram

Answers for Chapter 18

1. Which symbol is used to start a UML 2.5 State Machine Diagram?

image

A. a

B. b

C. c

D. d

E. e

F. f

Discussion:

A—No. While it often used to indicate the start of thing, e.g., a path on a map, it has no use in UML.

B—Yes, the solid ball is used in both Activity Diagrams and State Machines Diagrams to indicate the start of execution. In UML state machines, it is called the Initial Pseudostate. The ball symbol is also used as a Junction Pseudostate.

C—No, this symbol indicates a Final State.

D—No, this symbol indicates a Choice Pseudostate in UML state machine diagrams.

E—No, this symbol indicates a Terminate Pseudostate. It allows the modeler to produce a named exit point for a state. It is also used as a connection point reference on the boundary of a state, to refer to the named exit point by the same name. These usages are not tested on the Foundation exam.

F—No, this symbol indicates a named entry point in UML State Machine diagrams. It is also used as a connection point reference on the boundary of a state, to refer to the named entry point by the same name.

2. Examine the State Machine Diagram below. What state will the State Machine be in after the events e1, e2, e3, and e1 occur (in that order)?

image

A. It is not possible to tell.

B. S1

C. S2

D. S3

E. The diagram is not a valid State Machine Diagram.

Discussion:

Possible Starting State After event e1 next State After Event e2 Next State After Event e3 Next State After Event e1 Next State
S1 S2 S2 S3 S3
S2 S2 S2 S3 S3
S3 S3 S3 S3 S3

Image

No matter which state you start with, you wind up in S3.

3. Which list completely identifies the possible features of a transition?

A. trigger

B. trigger, guard

C. trigger, guard, state

D. trigger, guard, state, effect

E. trigger, constraint, effect

F. trigger, guard, effect

G. trigger, guard, effect, return

Discussion:

States, Constraints, and Returns are not possible features of a transition. This leaves, A, B, and F as possible answers. F is the complete answer.

4. What type of behavior should a system exhibit to be most appropriate for using a State Machine to help in understanding the manifest behavior of the system?

A. Continuous and self-adjusting behavior

B. Cooperating identical peer instances

C. Genetic Evolving Algorithms with feedback

D. Discrete Event-driven behavior

E. Time-based Schedule driven behavior

Discussion:

A and C—No. Self-adjusting and evolving algorithms cannot easily be captured in a predictable event-based response approach in a state-like manner.

B—No, cooperating peers usually work best in an agent-based approach. In any case, understanding how an individual responds will not give direct insight into the manifest or emergent system properties.

D—Yes, UML State Machines are best using for discrete event-driven behavior.

E—No, Time and scheduling algorithms may use state machines to process the time alarms, but the entire picture of the system is not appropriate for state machines.

5. Which statement best describes how a higher priority event interrupts the processing of a lower priority event in a UML state machine?

A. The events are taken from the event pool in strict priority order. Thus, a newly arriving high priority event can interrupt ongoing behavior.

B. There is no possibility for interrupting events because of RTC.

C. The UML 2.5 Specification does not allow for State Machine-mediated interrupts. However, changes to the priority of an object’s thread and changes to the resources available to the thread may cause a particular thread to be suspended and others to be enabled.

D. Higher priority events may be taken before lower priority events by an unspecified algorithm, causing effective interrupts.

E. The UML 2.5 Specification indicates that completion events are of higher priority than other events. This ordering causes completion events to be examined before external events, leaving interrupts in their wake.

Discussion:

Because of the RTC, no direct state machine mechanism allows for interrupts. Thus, A, D, and E are incorrect. They do not describe interrupts as no ongoing behavior is stopped. Though the facts they say about event processing order are correct, just the selection of a higher priority event before a lower priority event does not allow for interrupts with RTC, as every event’s processing still runs to its end. This leaves B and C as possible correct answers.

However, as completely banning interrupts may produce priority inversion problems, UML 2.5 allows for thread and resource-based prioritization to order the execution of different instances over time. The mechanisms for accomplishing this are not specified within UML. However, within a state machine, no incoming UML-defined event can interrupt the ongoing processing.

6. A State Machine Diagram has at least one Final State at the top level (at the State Machine diagram level), with more than one incoming edge. When does the State Machine finish?

A. The State Machine finishes when all the incoming edges to the Final State have supplied at least one token.

B. The State Machine finishes with the first transition to a top-level (diagram) Final State.

C. The State Machine finishes when the majority of incoming edges have transitioned to a top-level Final State.

D. The State Machine finishes when every top-level (diagram level) Final State has had a transition into it.

Discussion:

A—No, token arrival is not considered in State Machine Diagrams. Token arrival is part of UML 2.5 Activity Diagrams.

B—Yes, once a top-level final state has been reached the diagram, and the State Machine is done.

C—No, there is no concept of voting.

D—No, once any top-level final state is reached the diagram is done.

7. In a UML 2.5 State Machine, an expression may be surrounded by square brackets, [ ]. What does this expression mean?

A. An “invariant constraint” is surrounded by square brackets. The modelers state their intention that the model will enforce these constraint expressions to be true.

B. The use of square brackets announces that the expression is an “opaque expression”, whose meaning is context dependent.

C. Such expressions are “guard conditions” or “guard expressions”, that only allow passage when the contained condition is evaluated to be “true”.

D. The string inside the square brackets identifies a “behavior effect” that invokes an action by the same name on the state machines’ object.

E. The square brackets highlight an error in the original state machine. It is related to the use of Latin, sic (so, thus) to flag errors in the original material in the text.

Discussion:

A—No. In UML, constraints are surrounded by squiggly brackets {}.

B—No, though the contents may be opaque expressions, they are called “guard expressions” and have a specific purpose.

C—Yes. A guard expression can be used as path annotations when multiple paths may appear. When a guard expression is false, that path is prohibited. If more than one guard expression is true (which should not be), processing will follow one of the true conditions.

D—No, a behavior effect follows the “/” on a transition. It is possible that the guard expression is an opaque Boolean expression or a query operation on the object.

E—No, we do not repeat errors in UML. If we need to flag an error, we would use comments.

8. In UML 2.5, when might it be useful to use an exit action in a state machine?

A. An exit action might be useful when all of the possible ways of leaving a state must execute a common behavior or sequence of behaviors.

B. Upon leaving an exit state.

C. Upon entering a final state.

D. An exit action might be useful when most of the possible ways of leaving a state execute a common behavior or sequence of behaviors. The behavior may be an opaque behavior if necessary.

E. There is no such thing as an exit action in UML 2.5 State Machines. It indicates an exit condition.

Discussion:

An exit action is a UML 2.5 mechanism to provide a mandatory common behavior or sequence of behavior (an action) for all the possible ways of leaving a state. It is not necessary to use.

An exit condition is not a UML term. If we needed such a thing, we would use a Guard condition. Many modelers confuse exit action and exit condition.

9. What symbol is used to indicate that substates have been elided?

image

A. a

B. b

C. c

D. d

E. e

Discussion:

The symbols used to indicate a decomposition hierarchy looks like a stylized example of the model type being decomposed. The exact format is left to the modeling tool, though the UML specification gives examples.

A—Yes, this looks like the symbol used. In some places, the nodes look more like circles

B—No, this is the rake symbol used in static diagrams. BTW, at the time of this writing, the SysML Revision Task Force is debating adding the rake symbol as a possible indicator of the decomposition hierarchy of all model elements. Even if accepted by the SysML RTF, this does not change the rules for UML

C—No. This symbol is not used in UML.

D—No. This is the hamburger icon that is used in some user interfaces to indicate that selecting it will produce a menu of pages or options.

E—No. This symbol is not used in UML.

10. After this state machine completes, what is the value of X?

image

A. 11

B. 10

C. The state machine never ends.

D. 17

E. 20

F. 19

Discussion:

The [guard condition] is evaluated to determine if the transition should be taken. If the transition causes an exit to be taken, then the exit action is performed on the way out. This is followed by the transition and the associated action.

In this type of question, a good strategy would be to count it twice. If you get the same answer, go with it. If not, come back to the question with a fresh mind.

F—The correct answer is 19.

In some situations, it may be considered that such values are undefined after the machine ends.

11. Which of the following statements is true about UML State Machines?

A. Every State must have possible transitions in and possible transitions out.

B. Every State Machine diagram must have a final state.

C. The star-shaped state indicates concurrency.

D. Every transition is from one state to another different state.

E. A completion transition is triggered by the completion of the activity within its state.

Discussion:

A—No. A Final State may not have any transitions out.

B—No. Some State Machines are not intended to end. Consider a light switch.

C—No. There is no star-shaped pseudostate.

D—No. It is possible for a transition to lead back to the original state.

E—Yes. That is the definition of a completion transition.

12. Given the following State Machine fragment for an object of Class X, what is the minimum number of behaviors that have to be implemented inside Class X for the diagram to be correct?

image

A. 0

B. 5

C. 6

D. 7

E. 8

Discussion:

This is a tricky question because Class X need not implement any behavior. It could be a subclass of a group of Super classes that implement the required behaviors. Therefore, the correct answer is

A—0

However, if you believe this is too tricky the correct answer is (give yourself half credit)

B—5

Remember the [g] is a guard condition that could be implemented as a behavior, but need not be.

Send is the name of the incoming event, not a behavior.

A+B is an opaque behavior, but not required to be implemented by X.

13. In the STM diagram fragment below, we see five transitions marked with italic letters. Which option cannot have a guard condition added?

image

A. a

B. b

C. c

D. d

E. e

Discussion:

A—Correct. This is an initial transition. As a pseudostate, it is not allowed to have an event nor a guard because processing must not stop there. It can have an effect (behavior or action).

B—Incorrect. This is an internal transition. It can have a trigger, guard, and effect.

C—Incorrect. This is a completion (automatic) transition. It can have guard and effect but no trigger.

D—Incorrect. This is a normally triggered transition. It can have a trigger, guard, and effect.

E—Incorrect. This is a final transition. It can have a trigger, guard, and effect.

14. Assume the below state machine fragment is in State S1.1 when the do activity b4 finishes. What is the sequence of behaviors that then follows?

image

A. b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11

B. The diagram is malformed.

C. b5, b2, b7, b9

D. b5, b2, b7, b9, b10

E. b2, b5, b6, b7, b9, b10

F. b5, b2, b6, b7, b9, b10

Discussion:

A—Incorrect. This is just the list of possible behaviors is collating order.

B—Incorrect. The diagram is valid. For example, the transition between the states is a completion transition and needs no explicit trigger.

C—Incorrect. The list of behaviors is missing b6. This is executed during the transition between S1.1 and S2.1. It is also missing the do activity behavior b10.

D—Incorrect. The list of behaviors is still missing b6. This is executed during the transition between S1.1 and S2.1.

E—Incorrect. The order of the behaviors is incorrect. When leaving states, the exit behaviors are done inside out. That is, the exit behavior from the lowest state that is exited is executed first, and the exit behavior from the highest state is executed last.

F—Correct. Note that when entering states, the entry behaviors are done outside in. That is, the entry behavior from the highest state is executed first, and the entry behavior from the lowest state is executed last.

15. Examine the following diagram fragment. What statement properly describes the fragment?

image

A. A valid state diagram.

B. An invalid activity diagram.

C. A valid but not executable activity diagram.

D. Both a valid state or an activity diagram.

Discussion:
This question requires you to be sensitive to the differences between an activity and state diagram.

A—Incorrect. A state diagram may only have one Start Pseudostate.

B—Incorrect. The diagram is valid. However, see the next answer.

C—Correct. The syntax is correct. However, because node n1 requires e1 to be available before it starts and as e1 is an output of node n1, it is not logically possible for the start condition to occur.

D—Incorrect. It is not a legal state diagram.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.236.62