<< The Futures of Java | Home

Pop quizz Java: final vs. NPE, 0:1

Hah, that was a nice one! Given:

public class Foo extends Bar {
  final Object o;

  public Foo(Object o) {
    super(o);
    assert o != null;
    this.o = o;
  }

  @Override
  public void m() {
    assert o != null; /* Da bomb */
  }
}

Your task is to trigger the assertion in m(), while passing the one in the constructor. Hint: there's obviously not that much going on, so you might want to direct your attention to Bar

Tags : ,



Add a comment Send a TrackBack