Give some features of Interface?
Answer:
In Java, some of the features of an interface include:
-
Abstract methods: Interfaces can only contain abstract method declarations, and they cannot contain method implementations.
-
No Constructors: Interfaces cannot contain constructor methods.
-
100% abstraction: Interfaces are 100% abstract, which means that they only contain abstract methods and constants.
-
Multiple inheritance: Interfaces allow multiple inheritance, which means that a class can implement more than one interface.
-
Strong typing: Interfaces enforce strong typing, which means that variables declared as an interface type must only be assigned reference values that implement that interface.
-
Accessibility: Interface methods are public by default and cannot be declared as private or protected.
-
Constants: Interfaces can contain constant declarations, which are public, static, and final by default.
-
Marker interfaces: An interface that does not contain any methods or constants is known as a marker interface, such as Serializable, Cloneable, and Remote.
Related Articles:
This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.
Join Our telegram group to ask Questions
Click below button to join our groups.