• 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

Clarification about the answer of question 174 in chapter 3 (OCP 17 - Practice Tests)

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

With reference to the last part of the answer to question 174 in chapter 3 of the OCP Oracle Certified Professional Java SE 17 Developer Practice Tests: Exam 1Z0-829 (English Edition) book (Kindle edition).

The question asks the following:

Which of the following are the best reasons for creating a public static interface method? (Choose two.)



Six options are provided, the last of which reads:

F. Improve encapsulation of the interface.



The last part of the answers seems to indicate that interfaces support encapsulation.

Option F applies only to private static interface methods, not public ones.



My understanding is that encapsulation is related to state.  The class protects the state by setting the fields private and only allows access through getters and setters.  Given that interfaces have no (mutable) state, what role does encapsulation play in interfaces?
 
MyExamCloud Software Support
Posts: 734
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Meaning that it encapsulate behaviors we don’t want sub-interfaces or sub-classes to override or inherit.
 
author & internet detective
Posts: 41855
904
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
And also that we don't have to create another class with the method that isn't intended for reuse.
 
reply
    Bookmark Topic Watch Topic
  • New Topic