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

Java OCP: "classes inheriting the interface vs without an instance of the interface"

 
Ranch Hand
Posts: 74
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I'm busy with studying the Java OCP 17 by the Java Study Guide. In chapter 7 table 7.2 Interface member Acces, I do not understand exactly what is meant by:

column header 3: "Accessible from methods in classes inheriting the interface" (see attachement)
column header 4: "Accessible without an instance of the interface?" (see attachement)

Column 3:  what is exactly meant by "inheriting the interface"? Is that the keyword implements?
Is this what they are saying here?


Colunm 4: And if the class doesn't implement the interface, than by instantiate the class there is not any "instance" of the interface, but you can access the constant variable (because public static final) and the static method by interface name.
Is this what they are saying here?

Can anyone confirm this or am I complete wrong?
tabel-7.2.png
[Thumbnail for tabel-7.2.png]
 
Rancher
Posts: 5087
82
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nico van de Kamp wrote:Column 3:  what is exactly meant by "inheriting the interface"? Is that the keyword implements?
Is this what they are saying here?


Pretty much, yes - either implements or extends, or some combination of those.  You could have an interface A with method foo(), and interface B that extends A, and class C that implements B, and class D that extends C... and you could access method foo() from any of those.  If that's too confusing, then just take my answer as "yes".

Nico van de Kamp wrote:Colunm 4: And if the class doesn't implement the interface, than by instantiate the class there is not any "instance" of the interface, but you can access the constant variable (because public static final) and the static method by interface name.
Is this what they are saying here?


Yes.
 
Nico van de Kamp
Ranch Hand
Posts: 74
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok thanks, yesterday I've made some code examples which I will put here, but I think I understand it.

The interface


Code according 'Column 3':


Code according 'Column 4':
 
Nico van de Kamp
Ranch Hand
Posts: 74
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok thanks, yesterday I've made some code examples which I will put here, but I think I understand it.

The interface


Code according 'Column 3':


Code according 'Column 4':
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic