JAVA PROGRAMMING QUESTIONS UML and Patterns 1. What does “UML” mean and for whic
ID: 3595865 • Letter: J
Question
JAVA PROGRAMMING QUESTIONS
UML and Patterns
1. What does “UML” mean and for which types of languages is it best suited?
2. What are the three sections in a class diagram?
3. How is data member and method access shown in a UML class diagram?
4. What is aggregation?
5. How are inheritance and aggregation shown in a UML hierarchy diagram?
6. Draw an inheritance diagram.
7. Draw a class diagram.
8. What is the Adapter pattern?
9. What are common sorting patterns?
10. What is the Model-View-Controller pattern and when is it used?
11. What is a container and what is an iterator?
Inner Classes and Interfaces
12. What does an interface guarantee and what are they trying to accomplish?
13. What types of variables can appear in an interface?
14. How does an interface differ from an abstract class?
15. What does the Comparable interface do?
16. What is the Serializable interface used for?
17. What is the Cloneable interface used for?
18. What are the types of inner classes?
19. Can an object of a non-static inner class be instantiated without instantiating an object of an outer class?
Explanation / Answer
1. UML stands for Unified Modeling Language. This language provides a pattern which helps in easy visualization of design of a system. In other words, UML is a graphical language which can be useful in developing diagrams and models. Also, use of UML makes a clear structure of large and complex programs making Software development process more easier and efficient.
UML is naturally aligned towards Object-Oriented programming but it is very easy for UML to model procedural languages such as Visual Basic, C, COBOL, Fortran etc.
2. The 3 sections in a class diagram are:
- Upper section: It consists of the name of the class. It is a required section which defines the name of the object or class being talked about.
- Middle section: It consists of the attributes of the class. Attributes describes the qualities of the class. This section is only required when we need to describe a specific instance of a class.
- Bottom section: It consists of methods/ class operations. In this section, each operation has its own line of description of interaction with data.
3. Following is the structure of class diagram:
ClassName
vis attribute : type
vis operation (arg list) : return type
where
· vis = visibility (+ for public, - for private)
· attribute = data member
· operation = method (or constructor)
Here is an example of class diagram:
Student
+ Name: string
- Roll_No: int
+ Student(String)
+getName():String
+getRoll_No():int
Here, in the above example “Name” and “Roll_No” are the data members. The “+” and “-” signs in front of data members are the access modifiers.
4. Aggregation is a special type of relationship between two classes. This association/relationship is always one way i.e. directional association. It represents a HAS-A relationship. This is represented by a hollow diamond followed by a line.
ClassName
vis attribute : type
vis operation (arg list) : return type
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.