• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Possible typo in answer of question 21 in chapter 2 (Practice Tests)

 
Ranch Hand
Posts: 72
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

The example code, shown below, has a space after each letter.



Options D and E show the expected output without space.

D. If any lines that do not compile are removed, the output is LO.
E. If any lines that do not compile are removed, the output is EO.



Given that D is one of the correct answers, either the code needs to be updated or the options need to contain a space to match the output from the example.



 
Marshal
Posts: 8884
638
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, in the form this code is, it doesn't compile, i.e. Line 8 (Cannot resolve symbol 'c').

EDIT: just now read answers more carefully. Please ignore above.

And no, answers don't make sense anyway. Because they are shown as letter O and not 0 (zero) what I think there should be (assuming size is 0). But if it isn't shown how this method is called, I'm not sure how they could get 0 in the first place.
 
Liutauras Vilda
Marshal
Posts: 8884
638
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way, are you referring to any particular book, or some online videos or similar? So would be a bit easier to track down whoever is interested.
 
Albert Attard
Ranch Hand
Posts: 72
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply.

I was referring to the book OCP Oracle Certified Professional Java SE 17 Developer Practice Tests: Exam 1Z0-829 (English Edition).  I have the Kindle edition, in case that makes a difference.

The example does not compile on purpose and that's one of the options.


A. The code compiles.
B. The code does not compile due to line x1.
C. The code does not compile for another reason.
D. If any lines that do not compile are removed, the output is L 0.
E. If any lines that do not compile are removed, the output is E 0.
F. If any lines that do not compile are removed, the output is another



As you pointed out, I had a typo too.  The answers should have a 0 (zero) and not the letter O.  Thank you for pointing this out.
 
Marshal
Posts: 28271
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There must be more code than that. Given only that code, it's not known what the size of the Collection parameter kitties is, and so it's not possible to assert that "L 0" is the output. Or am I missing something else?
 
Albert Attard
Ranch Hand
Posts: 72
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply.

Please find question 21 in chapter 2 of the book OCP Oracle Certified Professional Java SE 17 Developer Practice Tests: Exam 1Z0-829 (English Edition) below for your reference.


What is true about the following method when calling with an empty ArrayList? (Choose two.)




A. The code compiles.
B. The code does not compile due to line x1.
C. The code does not compile for another reason.
D. If any lines that do not compile are removed, the output is L 0.
E. If any lines that do not compile are removed, the output is E 0.
F. If any lines that do not compile are removed, the output is another value.

 
Liutauras Vilda
Marshal
Posts: 8884
638
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like Paul and myself pointed out, you omitted a very important detail:

What is true about the following method when calling with an empty ArrayList?


So now that makes sense.

So getting back to your original question. Yes, if that code is as is, and answers as provided, the correct (or one of them) answer should be "L 0" and not "L0".
 
author & internet detective
Posts: 41933
910
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
Confirmed and added to errata
reply
    Bookmark Topic Watch Topic
  • New Topic