• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

[online] OCA/OCP Java SE 8 Practice Tests OCA mock question 79 errata

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some errors have sneaked into question 79 of the online mock OCA test.

As can be seen on the image, the Bear class names do not match. The class itself is with lower case 'b', where it is with upper case in the child class.
Then there is a date line that shouldn't be there at all. Both errors are not in the book.
q78.png
[Thumbnail for q78.png]
 
Marshal
Posts: 71629
312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There isn't a “following class”. There are two classes. Assuming the line about dates (No 17) shouldn't be there, and assuming there is no Bear class, I found four compile‑time errors:-

javac PolarBear.java
PolarBear.java:5: error: cannot find symbol
   protected in sing;
             ^
 symbol:   class in
 location: class bear
PolarBear.java:15: error: cannot find symbol
public class PolarBear extends Bear
                              ^
 symbol: class Bear
PolarBear.java:19: error: cannot find symbol
       sing() += 10;
       ^
 symbol:   method sing()
 location: class PolarBear
PolarBear.java:20: error: cannot find symbol
       return super.grunt() + 1;
              ^
 symbol:   variable super
 location: class PolarBear
4 errors

  • 1: There is no such datatype as in; maybe it should read int.
  • 2: The Bear class doesn't exist, so it cannot be extended.
  • 3: The returned type from sing() is a value, not a variable, and cannot therefore be the target of the += operator.
  • 4: The superclass doesn't have an implementation for sing(), so the keyword super won't work.
  • Note how helpful the error messages are sren't.
     
    Rune Thode
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The error messages are not very helpful...

    I forgot about the "datatype" in. In the book, it is correctly an int and the Bear class is called Bear, which then results in the error that grunt() cannot be overloaded with a stricter access modifier.
     
    Campbell Ritchie
    Marshal
    Posts: 71629
    312
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I am getting confused; which errors are in that screenshot and also in the exam itself? When I removed the part about dates, I got three error messages, all on different lines:-

    javac -d . PolarBear.java
    PolarBear.java:17: error: grunt() in PolarBear cannot override grunt() in Bear
       int grunt()
           ^
     attempting to assign weaker access privileges; was protected
    PolarBear.java:19: error: unexpected type
           sing() += 10;
               ^
     required: variable
     found:    value
    PolarBear.java:20: error: abstract method grunt() in Bear cannot be accessed directly
           return super.grunt() + 1;
                       ^
    3 errors

    [edit]The below image shows why we prefer not to see screenshots if at all possible.
    Screenshot-at-2021-01-13-10-21-43.png
    [Thumbnail for Screenshot-at-2021-01-13-10-21-43.png]
     
    Ranch Hand
    Posts: 429
    8
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Rune Thode wrote:Some errors have sneaked into question 79 of the online mock OCA test.

    As can be seen on the image, the Bear class names do not match. The class itself is with lower case 'b', where it is with upper case in the child class.
    Then there is a date line that shouldn't be there at all. Both errors are not in the book.



    Rune Thode wrote:In the book, it is correctly an int and the Bear class is called Bear



    The online experience does not appear to be under the authors' control.  I try to stick strictly to each book and its respective errata for the best experience.
     
    Rune Thode
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Campbell Ritchie wrote:There isn't a “following class”. There are two classes. Assuming the line about dates (No 17) shouldn't be there, and assuming there is no Bear class, I found four compile‑time errors



    The code in the book:



    The code in the online test:


    The explanation for the the answer is the same in both versions:

    Line 10 does not compile because the override reduces the visibility of an inherited method, with the package-private modifier being more restrictive than the protected modifier. Line 11 does also not compile, since the left-hand side of a compound assignment operator must be used with a variable, not a method. Finally, Line 12 does not compile because super.grunt() is inherited as an abstract method in the PolarBear class, meaning the parent class has no implementation. For these three reasons, Option D is the correct answer.



    So the differences are:
  • Line 2: bear instead of Bear
  • Line 3: protected in sing instead of protected int sing;
  • Line 13.5: There is only one return statement (there are two in the book).



  • Charles O'Leary wrote:The online experience does not appear to be under the authors' control.  I try to stick strictly to each book and its respective errata for the best experience.


    I thought you were also working on the online version. I did just notice that there are two return statements in the book version, which is not mentioned in the answer.
    The version I have is this one
     
    Charles O'Leary
    Ranch Hand
    Posts: 429
    8
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Rune Thode wrote:

    Charles O'Leary wrote:The online experience does not appear to be under the authors' control.  I try to stick strictly to each book and its respective errata for the best experience.


    I thought you were also working on the online version.


    Rune,

    To be perfectly honest, I'm now sticking to the book itself only.  When I want to better "emulate" the real computer oriented (mock) testing experience, I personally have found https://enthuware.com/ to contain less/no errors.  Enthuware even has a 100% money back refund to that effect.  

    Kudos to Jeanne, Scott, and Enthuware!
     
    I think I'll just lie down here for a second. And ponder this tiny ad:
    the value of filler advertising in 2020
    https://coderanch.com/t/730886/filler-advertising
    reply
      Bookmark Topic Watch Topic
    • New Topic