This week's book giveaway is in the Agile and Other Processes forum. We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line! See this thread for details.
I think there is an errata on Chapter 6, page 309 on the TIP box.
This rule applies to primitive types and object types alike.
You can't override a method that returns double with a method that returns int.
On class A:
On class B that extends class A:
The method on class B will not compile.
The book doesn't say it does. Just that you can't mix a primitive and void.
The book on the TIP box says the following:
A simple test for covariance is the following: given an inherited return type A and an overriding return type B, can you assign an instance of B to a reference variable for A without a cast? If so, then they are covariant. This rule applies to primitive types and object types alike. If one of the return types is void, then they both must be void, as nothing is covariant with void except itself.
Isn't it saying that the test for covariance described applies to primitive types and object types? Or I interpreted it wrong?