This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques and have Mario Casciaro & Luciano Mammino on-line!
See this thread for details.
Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

OCP Java SE 11 Programmer I Study Guide (Sybex) Possible Errata Bonus Exam 2

 
Saloon Keeper
Posts: 1343
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While after the fact, I can see what we mean here, I was truly perplexed as to what to put down for a couple of answers, not because I didn't know how Java works, but because of terminology:

Question 6 tb584704.JaSE11PrgISG.be2.67
Which statements about inheritance are correct? (Choose all that apply.)
A. A class can extend multiple interfaces.
B. Java supports multiple inheritance of parent classes.
C. A class inherits at most one class.
D. An interface may extend multiple interfaces.
E. A class can extend multiple classes.
F. A class can implement multiple interfaces.
You Answered Incorrectly.
Classes do not extend interfaces, but they can implement multiple interfaces, making option A incorrect and option F correct. Java supports single inheritance of objects, making option B incorrect and option E incorrect. While Java supports single inheritance, a class can inherit multiple classes. For example, RuntimeException inherits Exception, which inherits Error, and finally Object. For this reason, option C is incorrect. An interface can extend multiple interfaces, making option D correct.

Let's say I am fine with A being wrong and F being correct.
I found the terminology being used to make B False, but also C False, and E False as well to be weird or unexpected.
Some other presentations, including possibly your book, will say "Directly Extend one/more than one class" for true/false there.

If we said "a declaration of a class can directly extend one class" TRUE or "a declaration of a class can directly extend more than one class" FALSE
or "a declaration of a class can directly implement more than one interface" I'd buy those, but since Java 5, the following things that people should know make it confusing as to which answer to pick there:

The type Double, for instance, extends both Object and Number, for sure:
jshell> List<? extends Object> lol = new ArrayList<Double>()
lol ==> []

jshell> List<? extends Number> lon = new ArrayList<Double>()
lon ==> []


Now, it is true that a declaration of a class can only extend one class, but saying a class can only extend one class is a problematic statement for me.

Lastly, class declarations can not use the extends keyword for interfaces they implement.
But when we are working with Generics, we say they do all the time anyway, because these work:

jshell> List<? extends Serializable> los = new ArrayList<Serializable>()
los ==> []

jshell> List<? extends Serializable> los = new ArrayList<Long>()
los ==> []


Talking about what a declaration of a class can do is pretty clear to me, but leaving out the declaration word makes me confused in the ways shown above.

The keywords are unambiguous when talking about declarations, but when talking about what classes do/are (or using generics) the terminology gets all fuzzy again.
 
Jesse Silverman
Saloon Keeper
Posts: 1343
40
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:

Additional (more serious?) issue from another Bonus Exam 2 question from the book concerning the interaction between qualified exports and requires transitive.

I posted it in the Modules forum first because I was unsure/confused, but my experiments have confirmed my suspicions.  The answer and explanation should be changed:
https://coderanch.com/t/746063/java/requires-transitive-qualified-exports-JPMS#3464914

Thanks!
 
author & internet detective
Posts: 40748
827
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 replied to the module one in that thread. As for this one, I've added it to the list to look at
 
Get out of my mind! Look! A tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic