• Post Reply Bookmark Topic Watch Topic
  • New Topic

Errata for OCA/OCP Java SE 7 Programmer I & II Study Guide (K&B7)  RSS feed

 
Roel De Nijs
Sheriff
Posts: 11082
173
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 3, page 188, "Array elements are always, always, always given their default values, regardless of where the array itself is declared or instantiated.": if an array is only declared, the statement "Array elements are always given default values" can be confusing as there are no array elements. So regardless of where the array itself is instantiated, the array elements are always given a default value.

Suggested by Roger Jenkins in this topic.

Confirmed & added to the errata overview.
 
Mark Kevin
Ranch Hand
Posts: 44
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chapter 5, page 283

In the box at the bottom of the page I believe a semicolon is missing.
My program won't compile without it.

{ new Cat("Bilbo"), new Cat("Legolas"), new Cat("Bert")} }

Should be:

{ new Cat("Bilbo"), new Cat("Legolas"), new Cat("Bert")} };

Mark
 
Roel De Nijs
Sheriff
Posts: 11082
173
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark Kevin wrote:chapter 5, page 283

In the box at the bottom of the page I believe a semicolon is missing.

Should be:

{ new Cat("Bilbo"), new Cat("Legolas"), new Cat("Bert")} };

Added to the errata overview.
 
nick woodward
Ranch Hand
Posts: 370
11
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page 361:

The case constant must be a literal or final variable, or a constant expression, including an enum or a String.


Doesn't it have to be a compile time constant, not just a final variable?
 
Roel De Nijs
Sheriff
Posts: 11082
173
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nick woodward wrote:Page 361:

The case constant must be a literal or final variable, or a constant expression, including an enum or a String.


Doesn't it have to be a compile time constant, not just a final variable?

Added to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11082
173
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 6, page 316, Exam Watch, "In the first example , the case uses a curly brace and omits the colon.": using curly braces with a case is not a compiler error

Suggested by Mark Kevin in this topic.

Confirmed & added to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11082
173
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 6, page 370, Self Test, Question 13. If you think StackOverflowError is a runtime exception (or even a checked exception), you could still get the correct answer for this question. If you decide not to execute this code snippet and only check the correct answers (and not the explanation), you'll have a wrong understanding of the StackOverflowError class. So therefore it might be useful to make a few small improvements to this question.

Suggested by nick woodward in this topic.

Confirmed & added to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11082
173
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 6, page 337, "... execution transfers to the first line of that exception handler, line 8 in the catch clause.": when an exception is thrown while the code in the try block is executing, execution immediately transfers to the appropriate catch clause (and not to the first line inside that catch clause). So should be line 7 (instead of 8).

Suggested by Mark Kevin in this topic.

Confirmed & added to the errata overview.
 
Javier Garcia
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At page 28 at exam watch there is missing semicolon

static final int x = 1
must be
static final int x = 1;
 
Roel De Nijs
Sheriff
Posts: 11082
173
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Javier Garcia,

First of all, a warm welcome to CodeRanch!

Javier Garcia wrote:At page 28 at exam watch there is missing semicolon

static final int x = 1
must be
static final int x = 1;

Added to the errata overview.

Kind regards,
Roel
 
Tomasz Kamiński
Greenhorn
Posts: 4
IntelliJ IDE Java Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I found logic mismatch on page 892 in deleteRow() method section:

Current:
"When a ResultSet can detect deletions, the deleted row is removed from the ResultSet. When the ResultSet cannot detect deletions, the columns of the ResultSet row that was deleted are made invalid by setting each column to null."

Should be:
"When a ResultSet cannot detect deletions, the deleted row is removed from the ResultSet. When the ResultSet can detect deletions, the columns of the ResultSet row that was deleted are made invalid by setting each column to null."

Regards,
Tomasz
 
Tomasz Kamiński
Greenhorn
Posts: 4
IntelliJ IDE Java Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bad example for class name, page 914, code sample on the bottom:

Current:
(...) RowSetProvider.newFactory("com.example.MyRowSetProvider", null);


Should be:
(...) RowSetProvider.newFactory("com.example.MyRowSetFactory", null);

Regards,
Tomasz
 
Roel De Nijs
Sheriff
Posts: 11082
173
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tomasz Kamiński,

First of all, a warm welcome to CodeRanch!

Tomasz Kamiński wrote:I found logic mismatch on page 892 in deleteRow() method section:

Current:
"When a ResultSet can detect deletions, the deleted row is removed from the ResultSet. When the ResultSet cannot detect deletions, the columns of the ResultSet row that was deleted are made invalid by setting each column to null."

Should be:
"When a ResultSet cannot detect deletions, the deleted row is removed from the ResultSet. When the ResultSet can detect deletions, the columns of the ResultSet row that was deleted are made invalid by setting each column to null."

Added to the errata overview.

Kind regards,
Roel
 
Roel De Nijs
Sheriff
Posts: 11082
173
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomasz Kamiński wrote:Bad example for class name, page 914, code sample on the bottom:

Current:
(...) RowSetProvider.newFactory("com.example.MyRowSetProvider", null);


Should be:
(...) RowSetProvider.newFactory("com.example.MyRowSetFactory", null);

Added to the errata overview.
 
Roel De Nijs
Sheriff
Posts: 11082
173
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I discovered an errata item myself too

Chapter 15, Figure 15-7 (page 893).

The correct method name to delete a row in a ResultSet is deleteRow() (not delete()). The delete() method doesn't exist in the ResultSet interface.

Added to the errata overview.
 
Youwei Lu
Greenhorn
Posts: 1
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found a mistake in OCA Objective 8.0: Question 8 (Handling Exceptions)

Currently:

B, C, and D are (correct), examples of checked exceptions.

Should be:

B, C, and D are (correct), examples of Runtime exceptions.
 
Roel De Nijs
Sheriff
Posts: 11082
173
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Youwei Lu,

First of all, a warm welcome to CodeRanch!

Youwei Lu wrote:Found a mistake in OCA Objective 8.0: Question 8 (Handling Exceptions)

Added to the errata overview.

Kind regards,
Roel

PS. Have a cow for reporting an errata item with your first post!
 
Sergej Smoljanov
Ranch Hand
Posts: 472
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question in mock exam ocjp 1
58.
Given this directory structure at the root of the c: drive and the fact that no onter files exist:
|dir x - |
|..........| - dir y
|..........| - file a
Which are true (Choose all that apply.)
A. System.out.println(Paths.get("c:/x/z/..").normalize());
prints c:/x
B. System.out.println(Paths.get("c:/x/z/..").normalize());
prints c:/x/z/..
C. System.out.println(Paths.get("c:/x/z/..").normalize());
throws a NoSuchFileException
D. System.out.println(Paths.get("c:/x/z/..").toRealPath());
prints c:/x
E. System.out.println(Paths.get("c:/x/z/..").toRealPath());
prints c:/x/z/..
F. System.out.println(Paths.get("c:/x/z/..").toRealPath());
throws a NoSuchFileException

answer states that right is A and F
must be A and D
because http://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html#toRealPath%28java.nio.file.LinkOption...%29
Additionally, the resulting path has redundant name elements removed.
 
Sergej Smoljanov
Ranch Hand
Posts: 472
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question in mock exam ocjp 1
My assumption that A is wrong.
Reason: because thread-safe i understand that data in variable i must be consistent.
Initially i has 0.
When two different thread call add one with 10 and other with 20 argument after result i must contain 30, but i.compareAndSet will "Atomically sets the value to the given updated value if the current value == the expected value." but if current value is not as expected, data from one of call will be lost.
Correct me if i wrong
may-be-errata.png
[Thumbnail for may-be-errata.png]
 
Daniel Fernandez Boada
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page 685 says:

because a regular inner class cannot have static declarations of any kind.

This is not quite true. It is valid to define a static variable as long as it is final:
Is valid

Note that this is not valid for methods:
Is NOT valid
 
Min Boo
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At page 719 there is a list of 4 Thread constructors with the text (on page 720) "A little later, we'll discuss some of the other constructors in the preceding list.". But they never do. The only constructors discussed in the chapter are the first two of the list, which are discussed before this text.

Small thing, but made me wonder about the other two and had to google them.
 
Sergej Smoljanov
Ranch Hand
Posts: 472
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
https://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.1.7
5.1.7. Boxing Conversion

Boxing conversion converts expressions of primitive type to corresponding expressions of reference type. Specifically, the following nine conversions are called the boxing conversions:
From type boolean to type Boolean
From type byte to type Byte
From type short to type Short
From type char to type Character
From type int to type Integer
From type long to type Long
From type float to type Float
From type double to type Double
From the null type to the null type

I think that there is no AutoBoxing from int to number. I think this is boxing to Integer and after this is widening reference conversion.
Correct me if i wrong.
errata-kb.png
[Thumbnail for errata-kb.png]
 
Sergej Smoljanov
Ranch Hand
Posts: 472
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As i remember pattern decorator require that object implement same interface you delegating to.
Composition is not same. Or i wrong?
errata-kb.png
[Thumbnail for errata-kb.png]
 
Sergej Smoljanov
Ranch Hand
Posts: 472
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For last House has a Door is example of composition but not required that House is a Door.

 
Sergej Smoljanov
Ranch Hand
Posts: 472
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

answer must be C, D
errata-kb.png
[Thumbnail for errata-kb.png]
 
Sergej Smoljanov
Ranch Hand
Posts: 472
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

second line not compile!
errata-kb.png
[Thumbnail for errata-kb.png]
 
Marcus Biel
Ranch Hand
Posts: 51
IntelliJ IDE Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OCA/OCP Java SE 7, Programmer I&II Study Guide
Errata

Page 595:

Map Interface:
[...]
Like Sets, Maps rely on the equals method to determine whether two keys are the same or different.

I am just looking into the source code of TreeMap. It uses the compareTo method to determine if two keys are equal or not.
The java.lang.Comparable interface states:
* <p>It is strongly recommended, but <i>not</i> strictly required that
* <tt>(x.compareTo(y)==0) == (x.equals(y))</tt>.

So the way I understand it, generally saying:
Maps rely on the equals method to determine whether two keys are the same or different.

is wrong.

What do you think?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!