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