• Post Reply Bookmark Topic Watch Topic
  • New Topic

Mistake in exercise 22 of chapter 4 in book OCA Oracle Certified Associate Java SE 8 Programmer 1  RSS feed

 
Michael Migs
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

In the book "OCA Oracle Certified Associate Java SE 8 Programmer 1" by Jeanne Boyarsky and Scott Selikoff. Review question #22 for chapter 4 (p.227).

Order.result is called line 3 of class "OrderDriver". This actually triggers a compiler error because nothing indicates that the 2 classes are in the same package. Both start at line 1 and there are no import statement. Furthermore the static variable "result" is declared without any access modifiers making it package visible only.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37395
531
Eclipse IDE Java VI Editor
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,
They are both in the same package. In particular, they are both in the default package.  You can tell because they both begin with line 1 (as you noted) and there is no package name.
 
Michael Migs
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Thank you for your reply.

Indeed, it makes sense that if both classes start at line one without any package name, they are both in the default package... It's sometimes hard to see this kind of things when reading an exercice on paper because we have to imagine a context that does not really exist. If these classes were written on my IDE I would have automatically spotted that these classes belonged to the default package but on paper you have to remember the exam context.

I guess that's part of the exams game...
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37395
531
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True that! Luckily, you now know to watch out for that and won't be surprised by it on the exam
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!