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.
- Assessment Test
- from OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808
- Publisher: Sybex
- Released: December 2014
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.
Share this highlighthttp://www.safaribooksonline.com/a/oca-oracle-certified/11189939/