educative.io

Can interfaces have private properties?

In the tagged lesson, it is listed that interfaces can have private methods -

In the lesson on Multiple interfaces, it is said that all members in interfaces are public -

so which is it?


Course: https://www.educative.io/courses/object-oriented-programming
Lesson: Educative: Interactive Courses for Software Developers

Hi @Manish_Giri, your observation is correct.

An interface cannot have private methods. In most programming languages, interfaces define a contract for classes to implement, specifying only the method signatures that must be implemented by classes that implement the interface. Private methods are not part of this contract and are specific to the implementation details of a class. Therefore, interfaces typically do not include private methods.

This will be fixed in this course soon.