In real coding, you won’t be so concerned which is returned from each method due to autoboxing.
This code demonstrates three variations of the for loop you may not have seen. First, you
can declare a variable, such as x in this example, before the loop begins and use it after it
completes.
There is no requirement that second and third expressions in ternary operations have
the same data types, although it may come into play when combined with the assignment
operator.
Jeanne Boyarsky wrote:
Guram Savinov wrote:Chapter1 review question 12, answer F and explanation.
float primitive defaults to 0.0
0.0 is a double literal (same as 0.0d), so even if would be instance variable it's still not correct.
It would be corect if answer is 0.0F or 0.0f and it's an instance variable.
Agreed. Good catch. I've added this to the errata.
Maybe answer F for question 12 on page 46 should be 0.0f too.
toif we compile from /my/directory
if we compile from /my/directory and run it with java named.A.Bird
float and double primitives defaults to 0.0
float primitive defaults to 0.0