• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Potential error in Sybex CSG 17, p. 304, Initializing Instances

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

While studying with the excellent and very helpful Java 17 Study Guide I noticed a few potential errors. I'll make a separate post for each one so I can add all the relevant information without it getting too confusing, so here is the first one:

On page 300 in the section

Initializing Instances

, the fifth rule of

Initialize Instance of X

is specified as:

5. Initialize the constructor, including any overloaded constructors referenced with this().


See:

Initialize Instance of X
1. Initialize class X if it has not been previously initialized.
2. If there is a superclass Y of X, then initialize the instance of Y first.
3. Process all instance variable declarations in the order in which they appear in the class.
4. Process all instance initializers in the order in which they appear in the class.
5. Initialize the constructor, including any overloaded constructors referenced with this().

Therefore, when page 304 says

Per the fourth rule, we initialize the constructors.

it should instead say

Per the fifth rule, we initialize the constructors.



Secondly, also on page 304,

Per the third and fourth rules, H is printed on line 25, and G is printed on line 23, respectively.

should be changed to

Per the fourth and fifth rules, [...]

because on line 25 an instance initializer (fourth rule) is executed and line 23 is part of a constructor initialization (fifth rule).

The code snippet for reference:

 
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic