O'Reilly logo
  • Damian Wojakowski thinks this is interesting:

Next, the method hasHorns() looks like an overridden method, but it is actually a hidden method since it is declared private in the parent class. Because the hidden method is referenced in the parent class, the parent version is used, so the code outputs false, and option A is the correct answer.


Cover of OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808


It does not work.

hasHorns() is a private method of Deer class.
The object is created this way:

Deer deer = new Reindeer(5);

When you call deer.hasHorns() it breaks because you make a call to a private method.