• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Question/Errata for OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide page 554

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

On page 554 question 6, is it really correct to say "Line 7 creates the Hello class with the generic type Object since no type is specified"? I ask this because the compiler can infer that the type T is String because of the parameter passed to the constructor.

Thanks,
Guillaume
 
author & internet detective
Posts: 42135
937
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
Guillaume,
You're right. It's not. All three of these compile. Some with warnings, but they still compile.

 
Jeanne Boyarsky
author & internet detective
Posts: 42135
937
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
Three years later, I'm going through the errata in detail to fix them for the Java 11 book. (We are further along than it appears. I did my harder chapters first.)

It turns out this was not an errata. The generic parameter isn't used here. So even though it is in a class with a generic parameter, that doesn't apply to the new object.

 
reply
    Bookmark Topic Watch Topic
  • New Topic