Guram Savinov

Greenhorn
+ Follow
since Jun 04, 2014
Guram likes ...
IntelliJ IDE Java Ubuntu
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Guram Savinov

Page 135
Table 3.3

In real coding, you won’t be so concerned which is returned from each method due to autoboxing.


Actually, parseXxx(String s) and valueOf(String s) are not used during autoboxing.
Autoboxing can be done with help of methods like these (for Integer wrapper):
Page 85, Real World Scenario:

Should be:


because List<Integer> may contain null values
Errata has note about x output on page 82 and says: it can be removed, but it can't, because of this:

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.


Page 82
Example at the top:


Prints: 0 1 2 3 4 5
Instead of: 0 1 2 3 4

because of last output of x value
Page 73
Figure 2.4
default branch of switch statement can have optional break as well as case branches
Page 71

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.


That's not actually the truth, in the examle ternary operator result is of common type java.lang.Object which is passed to the System.out.println() method.

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.

I think you should correct question 14 by:
1. replacing

if we compile from /my/directory

to

if we compile from /my/directory and run it with java named.A.Bird


2. adding main method to the Bird class
Question 14 is not enough described: you didn't mention about runnning class in JVM, just about comiling.
Actually javac compiles any package declaration without any problem, but after that you should put .class file to appropriate directory to run bytecode.
And the Bird class must have main method if we going to run it in JVM.

For example:
1. you are in /my/directory
2. declare package: package my.directory.named.A
3. make subdirectories my/directory/named/A
4. put Bird.class from named/A to my/directory/named/A
5. run with: java my.directory.named.A.Bird
Chapter1 review question 11 explanation isnt clear about 0.0 literal too:

float and double primitives defaults to 0.0

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.
Page 22
hexadecimal (digits 0–9 and letters A–F)
lowercase 'a-f' is correct characters for hex literals as well
Same page 21
2^8 is 2 × 2 = 4 × 2 = 8 × 2 = 16 × 2 = 32 × 2 = 64 × 2 = 128 × 2 = 256
Should be 2^8 is 2 × 2^7 = 4 × 2^6 = 8 × 2^5 = 16 × 2^4 = 32 × 2^3 = 64 × 2^2 = 128 × 2^1 = 256
Page 21
Java Primitive Types
Example of long '123' should be '123L' like the float example '123.45f'
As you wish, but for me this is a misconception.
Maybe we should ask some other people about the explanation.