What 
🏆 Can draw UML classes
The basic UML notations used to represent a class:

📦 A Table
class shown in UML notation:

class Table{
Integer number;
Chair[] chairs = null;
Integer getNumber(){
...
}
void setNumber(Integer n){
...
}
}
The 'Operations' compartment and/or the 'Attributes' compartment may be omitted if such details are not important for the task at hand. 'Attributes' always appear above the 'Operations' compartment. All operations should be in one compartment rather than each operation in a separate compartment. Same goes for attributes.

The visibility of attributes and operations is used to indicate the level of access allowed for each attribute or operation. The types of visibility and their exact meanings depend on the programming language used. Here are some common visibilities and how they are indicated in a class diagram:
+
:public
-
:private
#
:protected
~
:package private
📦 Table
class with visibilities shown:

Which of these follow the correct UML notation?

- 1
- 2
- 3
- 4
- 5
- Incorrect : Attributes compartment should be above the Methods compartment.
- Incorrect : All attributes should be inside the same compartment.
- Correct
- Correct : Both Attributes and Methods compartments can be omitted.
- Correct : The Attributes and Methods compartments can be empty.
Draw a UML diagram to represent the Car class as given below. Include visibilities.
class Car{
Engine engine;
private List<Wheel>[] wheels = null;
public String model;
public void drive(int speed){
move(speed);
}
private move(int speed){
...
}
}