Page 1356 - AP Computer Science A, 7th edition
P. 1356

37. (B) Choice B is fine: b, the Beginner, is-a WeakPlayer. Choices A and C will each cause a ClassCastException to be thrown: You can’t cast a GoodPlayer to a WeakPlayer, and you can’t cast a WeakPlayer to a Beginner. Choices D and E will each cause a compile-time error: The parameter must be of type WeakPlayer, but w and b are declared to be of type TennisPlayer. Each of these choices can be corrected by casting the parameter to WeakPlayer.


































































































   1354   1355   1356   1357   1358