• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Potential Errors in Assessment Test Answer #3 (Java OCA 8 Programmer I Study Guide)

 
Alan Couze
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm either highly confused, or the answer key for Assessment question 3 is incorrect. It says that the answers are C, D, E.

I understand that 'C' is a correct answer, since there is an invalid override (more restrictive access modifier in the class is defined).

Answer 'D' does not seem to be a correct answer. The explanation says "Next, the class Cougar implements an overloaded version of getTailLength(), but since the declaration in the parent class Puma is invalid, it needs to implement a public version of the method. Since it does not, the declaration of Puma is invalid, so option D is correct." However, class Cougar does implement a public version of getTailLength().

'E' seems to be a correct answer, however the answer section says "Option E is incorrect, since Puma is marked abstract and cannot be instantiated." Shouldn't it say "Option E is correct"?

So I believe that C,E are correct answers, but D is not.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alan Couze wrote:I understand that 'C' is a correct answer, since there is an invalid override (more restrictive access modifier in the class is defined).

I agree with this one as well!

Alan Couze wrote:Answer 'D' does not seem to be a correct answer. The explanation says "Next, the class Cougar implements an overloaded version of getTailLength(), but since the declaration in the parent class Puma is invalid, it needs to implement a public version of the method. Since it does not, the declaration of Puma is invalid, so option D is correct." However, class Cougar does implement a public version of getTailLength().

Class Cougar does not implement a public version of getTailLength as defined in the interface HasTail, class Cougar has an overloaded (public) version of the getTailLength method (which takes an int as parameter). And that's why the class declaration of Cougar is invalid and answer D is correct.
But there's a typo as well in this ex planation. Should be: Next, the class Cougar implements an overloaded version of getTailLength(), but since the declaration in the parent class Puma is invalid, it needs to implement a public version of the method. Since it does not, the declaration of Cougar is invalid, so option D is correct.

Alan Couze wrote:'E' seems to be a correct answer, however the answer section says "Option E is incorrect, since Puma is marked abstract and cannot be instantiated." Shouldn't it say "Option E is correct"?

That's indeed a typo! Class Puma is abstract and on line 7 the code tries to instantiate this class, so that's a compiler error and thus option E is correct (and not incorrect).

Alan Couze wrote:So I believe that C,E are correct answers, but D is not.

The correct answers are spot-on. For this questions answers C, D, and E are correct. The explanation has two minor typos which will be reported to the publisher (by one of the authors).

Hope it helps!
Kind regards,
Roel
 
Alan Couze
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see what I did wrong. I missed the fact that the getTailLength(int) is an overloaded method - I missed the int parameter! Although at least the typos will be reported. Thanks.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alan Couze wrote:I see what I did wrong. I missed the fact that the getTailLength(int) is an overloaded method - I missed the int parameter!

These code snippets are excellent to prepare you for the mock (and actual) exams, because having an eye for detail is very important! As you discovered yourself, missing an int parameter could make the difference between compilation success and compilation failure.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've updated the errata list for both.

And I agree with Roel. The fact that you are noticing these is a good sign you will do well on the exam. And be a good programmer in general!
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:I've updated the errata list for both.

Should also be added to the "online materials" section as the assessment test can be taken online as well...
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:
Jeanne Boyarsky wrote:I've updated the errata list for both.

Should also be added to the "online materials" section as the assessment test can be taken online as well...

I'm not duplicating everything in the online materials section. Think of it as web page normalization.

Besides I'm going to report the online ones so eventually they won't be wrong anymore...
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Besides I'm going to report the online ones so eventually they won't be wrong anymore...

If you are reporting them, then you can consider my previous post as non-existing
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic