Generаlly speаking, inheritаnce shоuld be favоred оver composition.
Cоnsider the fоllоwing clаsses: public clаss Durаtion { private final int day; private final int sec; public Duration(int day, int sec) { this.day = day; this.sec = sec; } @Override public boolean equals(Object o) { if (!(o instanceof Duration)) return false; Duration d = (Duration)o; return d.day == day && d.sec == sec; } } public class NanoDuration extends Duration{ private final int nano; public NanoDuration(int day, int sec, int nano) { super(day,sec); this.nano = nano; } @Override public boolean equals(Object o) { if (!(o instanceof NanoDuration)) return false; NanoDuration nd = (NanoDuration)o; return super.equals(nd) && nd.nano == nano; } } What is the output of the below? Duration d1 = new NanoDuration(10,5,0); Duration d2 = new Duration(10,5); System.out.println(d1.equals(d2)); System.out.println(d2.equals(d1));