#java #interface #KingofTechniques
@kingoftechniques6864
An Interface in Java programming language is defined as an abstract type used to specify the behavior of a class. An interface in Java is a blueprint of a class. A Java interface contains static constants and abstract methods.
An interface in Java is a blueprint of a class. It has static constants and abstract methods.
The interface in Java is a mechanism to achieve abstraction
There can be only abstract methods in the Java interface, not method body. It is used to achieve abstraction and multiple inheritance in Java
Why use Java interface?
There are mainly three reasons to use interface. They are given below.
It is used to achieve abstraction.
By interface, we can support the functionality of multiple inheritance.
It can be used to achieve loose coupling.
An interface is declared by using the interface keyword. It provides total abstraction; means all the methods in an interface are declared with the empty body, and all the fields are public, static and final by default. A class that implements an interface must implement all the methods declared in the interface.
interface [interface_name] {
// declare constant fields
// declare methods that abstract
// by default.
}
Sur cette page du site, vous pouvez voir la vidéo en ligne Advance-Java Interface in Java #19 durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur King of Techniques 21 mars 2022, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 134 fois et il a aimé 3 téléspectateurs. Bon visionnage!