Week 7

Type checking and name resolution

    1. Construct a Java program that creates a generic List<String> but which manages to fill this list with Integer values. At what kind of instruction will such "misbehaving" code usually fail at runtime?
    2. Which type is a subtype of each reference type? Why is that so?
    3. Write an actually useful Java program that is unfortunately rejected by Java's type checker. What changes do you have to perform in order to make the program compile?
    4. Construct a (legal?) Java program that crashes SUN's Java compiler during name resolution. (Not a typical exam question!)

Maintained by Eric Bodden. [HOME]