Saturday, July 31, 2010

Downcasting: HorseTest.java

Courtesy of SCJP Sun® Certified Programmer for Java™ 6 Study Guide Exam (310-065) (9780071591065)
Chapter 8, Question 5
















This code would work if you either
1. Change Object to Horse in line 9
2. Downcast obj.name on line 10 by re-coding as ((Horse)obj).name

No comments:

Post a Comment