Aufgabe 1

1)

5++ is a compile error, as we can only increment on variables, not on values.

Aufgabe 2

Don’t be fooled by access bullshit like for (int k : a) sum += a[k], this is not a straight enumeration through the array, but access the array at the indices in the array. So for a = [0, 2, 3, 3, 2, 1], it accesses a[0] + a[2] + a[3] + a[3] ... .

Aufgabe 4

The following rules apply to overriding:

  1. Same Name: The method in the subclass must have the exact same name as in the superclass.
  2. Same Parameters: The parameter list must match exactly (type, order, and number).
  3. Covariant Return Type: The return type must be the same or a subtype of the overridden method’s return type.
  4. Not Private, Static, or Final: Private, Static and Final methods cannot be overridden.
  5. Visibility: The overriding method must have equal or broader visibility: Visibility hierarchy: public > protected > default (i.e. no modifier) > private (not overridable).