• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 42073
932
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 42073
932
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 95
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 42073
932
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 95
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 95
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 42073
932
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 95
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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


Thanks Jeanne!
I'm proud of it!
 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic