• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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.
 
Sheriff
Posts: 11338
177
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: 11338
177
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.
 
author & internet detective
Marshal
Posts: 38169
618
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: 11338
177
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: 38169
618
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: 11338
177
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
 
Ranch Hand
Posts: 94
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I resurrect this thread because I got another doubt about this same question, that is the last possible option, the option G.
It says:
G: The output can't be determined from the code provided.

I don't understand why it is not considered a correct option.
In fact you could not determine what is the output of the code provided since the multiple errors in it.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 38169
618
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniele Barell wrote:I resurrect this thread because I got another doubt about this same question, that is the last possible option, the option G.
It says:
G: The output can't be determined from the code provided.

I don't understand why it is not considered a correct option.
In fact you could not determine what is the output of the code provided since the multiple errors in it.



"he output can't be determined from the code provided" - This means that the program runs successfully but you can't tell what the output is. That's something that happens with random numbers and threads. Neither of those are in exam scope for the OCA. This is an answer that makes sense for the OCP. We sprinkled it in some of the OCA questions so you get used to seeing it as an answer. It's pretty much guaranteed to be wrong on the OCA though!
 
Daniele Barell
Ranch Hand
Posts: 94
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:
"he output can't be determined from the code provided" - This means that the program runs successfully but you can't tell what the output is. That's something that happens with random numbers and threads. Neither of those are in exam scope for the OCA.


Now I see, Jeanne.
Thanks a lot!
 
Daniele Barell
Ranch Hand
Posts: 94
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:...

"The output can't be determined from the code provided" - This means that the program runs successfully but you can't tell what the output is. That's something that happens with random numbers and threads. Neither of those are in exam scope for the OCA. This is an answer that makes sense for the OCP. We sprinkled it in some of the OCA questions so you get used to seeing it as an answer. It's pretty much guaranteed to be wrong on the OCA though!



Ah, by the way!
Studying your book on Garbage Collection, I noticed that there is a case in which this answer could be correct also in OCA questions:

For example:
Following the code below: What's the output of the following code?


a)-0-1-2-3-4
b)-4
c)-0
d)The output can't be determined from the code provided
e)The code won't compile
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 38169
618
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ooh good one! Glad I said "pretty much guaranteed to be wrong" vs "always wrong." I felt like I was forgetting something from the OCA and you found it. Have a cow!
 
Daniele Barell
Ranch Hand
Posts: 94
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:Ooh good one! ...Have a cow!


Thanks Jeanne!
I'm proud of it!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!