Dose The abstract class have attributes? - uml

My Question in Analysis and design system with UML Methodology
Dose the abstract class have attributes or just Methods?
Thanks.

Can have both.
If at least one method is abstract, a class is abstract.

Related

Are the relationships and class models in this diagram correct?

So, I'm trying to get better with labeling my class diagrams and wanted to know if I have laid out the class diagrams here in the correct fashion. I've tried adding in an abstract class for Blood Pressure as both classes have similar methods which both can implement.
Edit: After a few changes the current design of the diagram is as following:
abstract class for Blood Pressure as both classes have similar methods which both can implement.
in that case you have that :
or that :
(I hidden class compartments to not have to enter the members)
There is no standard/normalized stereotype AbstractClass (nor abstract), the class have the attribute isAbstract and if it is true the name is drawn in italic as you did

how to design a qualified uml class diagram?

A question from java interview:
You have to design a system that will manage 3 ducks:
The first one knows how to swim and fly, the second knows to swim and to hunt, the third knows to swim, fly and hunt. Describe the UML class diagram and explain the terms abstract class and interface. End of question.
In my opinion, i would create a "Duck" class with a method swim() in it, and 2 more classes "flyingDuck" and "huntingDuck" will derive from "Duck", and will contain the methods fly() and hunt() respectivly. One more class will be "universalDuck" and it will derive from "huntingDuck" and will contain the method eat(). What do you think ? Is this a good design or it's better to do it with interfaces ?
Why do you want to model a "universalDuck" extending "huntingDuck" by the method eat()? Was this asked for in your Java interview question?
Since the question asked for explanations of the terms abstract class and interface, you are probably expected to use these concepts in your model. For having a duck3 as an instance of a class that inherits both fly() from "flyingDuck" and hunt() from "huntingDuck" you will need to use interfaces for "flyingDuck" and "huntingDuck" because in Java you can only have multiple inheritance from interfaces.

How should I explain UML class diagram?

I have created a design using class diagram. However I was asked to give some explanation on the class diagram.
IMO, class diagram is fairly. For example, if a class is labeled as "Cat", am I going to explain, this "Cat" class represents "Cat"?
What is the best way to explain UML class diagram?
saying class Cat represents cats is one thing you can do, which is maybe not very exciting, though. More interesting to explain might be: associations, abstract classes, interfaces, inheritances, etc. is there any design pattern you are using? maybe explain them.
I hope this will help!
Suppose you have to explain this class diagram to your client in lieu your manager will. Just think how you will define all the responsibilities of each class present in that diagram. Give one-liner definition of its properties, methods, parent and child classes etc (go in bit more details when needed as well).
Define what would be the flow and how one class will link to another one.
For example:
Is your class 'cat' has any association with class Animal or interface IAnimal. You can think more of it and go better.
whatever the type of uml diagram, you should always add some explanantions in natural language.
at least explain some key aspects of the solution : this has a reference to this
this inherits from this class and do not need to override this operation.

Which relationship line to use in a UML class diagram?

In a UML class diagram I want to show the relationship between two classes where the second class is the type of a class variable in the first.
I've looked here but am still unsure which relationship I should be using.
I think it may be the Dependency relationship but I am unsure.
Which should I be using?
It sounds like a composition(has a) but would need to hear more about your diagram.

In UML, do you have to show the concrete implementation of an abstract method?

I'm drawing some UML in which a concrete class inherits from an abstract class which defines a pure virtual method. Is it required to show this method in the concrete class as well? It's implied by inheriting from the abstract class.
Nope, you don't need to. in fact, in general, don't put any more in the UML than you must have to clarify what you're saying, unless you're (god forbid) trying to generate code from it.
The best guide I know of for UML is UML Distilled by Martin Fowler.
The funny thing about UML is that it has a pretty loose and varied definition. Most things that are called UML are actually not much more that block diagrams. There is a lot of ambiguity in any UML implementation.
I would say that if you are doing this for a presentation or architectural diagram, you can take care of a lot of the possible ambiguity with 'words'. If you will be generating code from it using some application, you should check the docs of that particular application.
It's implied and in fact, many CASE tools would show you the inherited method as part of the list of the methods of the subclass when clicking on the class at looking at its properties (and some CASE tools even have the option of showing also the inherited methods in the diagram)

Resources