Hi, I recently went through the first of the ePractice exams for SCJA certification and came across a UML question that I answered incorrectly. I am no UML guru, so I was hoping someone would be able to help clarify my thoughts on the question.
The question was basically "How to implement Interface X, Interface Y, Class Z in Java" where Z implemented interfaces X and Y. The actual code for the answers is unimportant - suffice it to say that there were a number incorrect fragments, a correct Java fragment, and a statement that the UML diagram was illegal.
I picked the correct Java code out immediately, but then looked a little deeper, and noticed that the interface operations of Interface X and Interface Y were not italicised. My UML reference in preparation ("UML for the Java Associate PDF" from HF) suggests that abstract operations are italicised within UML diagrams.
As interfaces cannot provide implementation of methods (and as I have seen several carefully worded questions to catch out the participant within the Sun certification exams) I then deduced that as interface X and interface Y appeared to provide concrete implementation of their methods, the diagram was illegal.
This was marked as incorrect. However, the explanation I received did not mention the above observations, so I was hoping someone would be able to explain the declaration of abstract methods with interfaces in UML in relation to the question described above, as I am now a little confused!
I can provide a question reference if necessary - although I am quite sure I cannot post the actual question here!
As you correctly state, an interface cannot contain any concrete method, all operations mentioned in an interface are inherently abstract. Hence, as far as I know, the UML does not require that operations inside an interface are written in italics. Italics is only required if you add an abstract method to a class.
The same is true for a utility class in UML. A utility class is a class that contains only class-scope (static) attributes and methods, e.g. the Math class in java. In UML, a static attribute or method is denoted by underlining it (instead of using italics for abstract ones). Also, a class marked as a utility class does not require underlining each attribute and method, because attributes and methods are by default static in a utility class.