Short Questions for Class Diagram

  • 1 Define association class, singleton class, active class and concrete class. Give example of each.

    Answer:

    • Association Class:An association class allows you treat an association itself as a class , and model it with attributes, operations, and other features. It is illustrated with a dashed line from the association to the association class. For example Company Class associated with Person with association class Hire. 
    • Singleton Class: A class which ensure that only once instance to be created in the life cycle of application. In class diagram this class is marked with a '1' in the upper right corner of the name compartment. AppConfigurations class in any application usually keep the settings of the application and is implemented as singleton class. 
    • Active Class: An active object runs on and controls its own thread of execution. The class of an active object is an active class. It is shown with double vertical lines on the left and right sides of the class box in class diagram. For example any class that implements Runnable interface in JAVA or extends Thread class is an active class. 
    • Concrete Class: Usually a class that implement an interface or another abstract class is called a concrete class in object desinging, However a non-abstract class is also a concrete class. For example Student in CUONLINE is a concrete class.


  • 2 What are the types of relationship between classifiers (Classes and interfaces) in class diagram? Describe each one along with their UML notation.

    Answer:

    Every classifier in the class diagram relate to another classifier through one of the following relationship:

    1. Dependency: If class A is using the state or behavior of another class B for initializing its state or performing his responsibility, Then we say that class A depends on class B. It is show by a dashed arrow line from A into B.
    2. Interface implementation: If class A implements an interface IA in the class diagram then we say A implements IA. In pure object oriented languages one class can implement many interfaces. In UML it is denoted by a dashed line with an un-filled triangle into IA from A.
    3. Inheritance: If class A extends another class B. The it is a parent (B) Chile (A) relationship. In pure object oriented languages one class can extend only one another class unlike interfaces. Inheritance is shown by a solid line from child into parent with an un-filled triangle. 
    4. Association: If class A initializes class B instance for a short time of span for accessing its state or behavior and then the instance gets destroyed then we call it an association. In other words class A uses class B services for a short time. It is denoted by a solid line between classifier. I uni-directional then optional arrow can be added into B class, Otherwise for bi-directional association no arrow is shown.
    5. Aggregation: If class A uses class B for its whole life and have no control on the life of instance B then we call it aggregation. One possibility for this relationship is when you pass instance of B as parameter to constructor of A. Aggregation allows Dependency Injection (DI) also called Inversion of Control (IoC) principle, which is the base of latest development trend for test driven development TDD. It is denoted by an un-filled diamond into A with a solid line from B.
    6. Composition: If class A uses class B for its whole life and also control the life of instance B then we call it composition. One possibility for this relationship is when initialize instance of B in constructor of A or at class level. This is also a whole part relationship. It is denoted by an filled diamond into A with a solid line from B.


  • 3 Briefly explain operations and methods in the class diagram. Describe their default visibility, UML formats and how they can be represented for any programming language

    Answer:

    Operations

    • Shown in one compartment with following format
      • visibility name (parameter-list) {property-string} UML 1
      • visibility name (parameter-list) : return-type {property-string} UML 2
    • Operations are usually assumed public if no visibility is shown
    • UML allows the operation signature to be written in any programming language
      • + getPlayer( name : String ) : Player {exception IOException}
      • public Player getPlayer( String name ) throws IOException
    • An operation is not a method, It’s a declaration, with a name, parameters, return type, exceptions list, and possibly a set of constraints of pre-and post-conditions
    Method

    • Methods are implementations
    • Shown in following ways
      • in interaction diagrams, by the details and sequence of messages
      • in class diagrams, with a UML note symbol stereotyped with «method»
    • Method is part of dynamic modeling
    Operation Issues in DCDs

    • The create Operation in DCDs is mapped to the constructor definition
    • Operations to Access Attributes are skipped to reduce noise i.e. getPrice, setPrice


  • 4 How operations are represented in class diagram and also show its signature in UML for programming languages?

    Answer:

    • Shown in one compartment with following format:
      • visibility name (parameter-list) {property-string} UML 1.
      • visibility name (parameter-list) : return-type {property-string} UML 2
    • Operations are usually assumed public if no visibility is shown
    • UML allows the operation signature to be written in any programming language
      • + getPlayer( name : String ) : Player {exception IOException}
      • public Player getPlayer( String name ) throws IOException
    • An operation is not a method, It’s a declaration, with a name, parameters, return type, exceptions list, and possibly a set of constraints of pre-and post-conditions


  • 5 What can be represented by a note symbol in class diagram?

    Answer:

    May represent several one of the following:

    • UML note or comment, which by definition have no semantic impact
    • UML constraint, in which case it must be encased in braces '{…}’
    • A method body the implementation of a UML operation


  • 6 Describe some guidelines for showing attributes in class diagram.

    Answer:

    • Use the attribute text notation for data type objects and the association line notation for others.
    • The end of an association can have a navigability arrow, optional rolename (attribute name) and may also show a multiplicity value
    • Collection Attributes with Attribute Text and Association Lines can be shown using
      • Text notation format e.g. salesLineItems : SaleLineItems[1..*]{ordered}
      • Adding property string ({ordered, List}) to the end arrow of association line


  • 7 What are the ways to show attributes in class diagram?

    Answer:

    Attributes of a classifier are shown in following ways:

    • Attribute text notation
      • Attributes are usually assumed private if no visibility is given
      • visibility name : type
      • such as currentSale : Sale.
    • Association line notation
      • a navigability arrow pointing from the source to target object
      • a multiplicity at the target end, but not the source end
      • a rolename (currentSale) only at the target end to show the attribute name
    • Both together


  • ×

    Hidden Questions!

    Some short questions are not visible. Usually teachers hides their visibility if they are few in number. Subject Expert recommends them to have more than 70+ questions against the topic and make them public.

Contact Us

support@subexpert.com
Write to Us View Help
Subject Expert Logo

Subject Expert

Learn and Evaluate

Follow Us
© 2020 - Subject Expert