• 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

Doubt in interface question

 
Ranch Hand
Posts: 125
Scala Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is from diagnostic test on ExamLab, question number 6. I can't copy the text from there, but one of its correct answer states that "An interface "is-a" java.lang.Object".
But interface doesn't extend java.lang.Object class, how can their "is-a" relationship be true?
I've read that an interface does not extend java.lang.Object, it just implicitly declares all the methods in java.lang.Object class as public abstract.

This is the explanation given, but I can't understand it:
Answer-I is correct, because any object, which has an interface-reference, can be implicitly casted to a java.lang.Object reference, without doing any explicit cast.

Here is the screenshot of the queston:
 
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it's just the wording that is a bit off. An interface is a concept - it doesn't exist in the JVM, and as such is not an object (or an Object).

Now, at runtime, if you have a reference with the type of an interface, that does point to an object, and thus can be cast to Object.

So maybe Answer I should be something like "An object of an interface type "is-a" java.lang.Object."
 
Sidharth Khattri
Ranch Hand
Posts: 125
Scala Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:I think it's just the wording that is a bit off. An interface is a concept - it doesn't exist in the JVM, and as such is not an object (or an Object).

Now, at runtime, if you have a reference with the type of an interface, that does point to an object, and thus can be cast to Object.

So maybe Answer I should be something like "An object of an interface type "is-a" java.lang.Object."



Thanks for your response Ulf.
I hope I don't get this kind of ambiguous answer choice in the exam.
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic