ILO Course


Go back

A lot of questions that the teacher is usually asking us. They are all about the practical classes, while Java-related questions are in the Java course.

Question 1

What's the design pattern for the class Group in TP Figures, which contains a lot of Figures. Note that Group is also a Figure.

It's the Composite design pattern.

Question 2

In TP Tchat, in the method void updateMessages(), which operations were intermediary?

  • stream.forEach((Message m) -> appendMessage(m));
  • stream = stream.filter(authorFilter);
  • Stream<Message> stream =;
  • stream = stream.sorted();
The 2nd and the 4th ones, since in both we are consuming our stream to create a new one.

Question 3

In TP Tchat, Controller implements ListChangeListener<String>. What's the design pattern?

It's Observer/Observable design pattern.

Question 4

In TP Tchat, the teacher used Map<String, Color> colorMap = newTreeMap<String, Color>() to store the color(Color) for each user (String). What instructions are valid?

  • colorMap.put("Olias", Color.BEIGE);
  • colorMap.put(Color.AQUA, "Antholien");
  • colorMap.get(Color.GREEN);
  • colorMap.get("Cloris");
The 1st one since we have String-Color and the 4th one since get method take a key and the key has the type String since we are associating for each username a color.

Question 5

In TP Tchat, the class ChatClient is handling the message (send/receive). It is M, V, or C in MVC?

I think it's M, since ChatClient can be viewed as a class interacting with a Database (the server here).

Question 6

In TP Tchat, we were giving Runnables to Platform.runLater. True or False?

  1. the runnable classes were declared as inner classes (classes internes)
  2. the runnable classes were declared as nested classes (classes imbriquée)
  3. we could have used lambda expressions
  4. we couldn't have used lambda expressions
  5. we could have used anonymous classes
The classes are not static, so they were declared as inner classes. We could have used a lambda expression, since Runnable is a functional interface. We could have used an anonymous class, it works no matter the class.

Question 7

In TP Figures, what's the design pattern used when we are calling equals(Figure f) inside equals(Object obj) among Template Method, Equalizer, Decorator, and Adapter?

My first trough is the Template Method because equals, hashcode, ... are methods defined in the template that is named Object. But, since this is not "about equals" as it looks like this is about "the same method but more specialized" then I would pick Decorator=Wrapper because it looks like a Parser that becomes a XMLParser/PDFParser/... to me.

Question 8

In TP Lists, CollectionList<E> extends AbstractCollection<E> which is a Collection<E> wrapping a ForwardList<E>. What's the design pattern among Iterator, Decorator, Composite, and Adaptor?

First, I checked that ForwardList wasn't a Collection. Hence, I would pick the pattern Adaptor because we are providing an interface (a Collection) for our ForwardList.