In this tutorial we will learn about the interface keyword in Java language
interface is one of the features in Java instead of multiple inheritances. This keyword is used to define an interface in Java. an interface is similar to the class but it is not class. The Java interface does not contain an implementation of the methods, it is only the signature of the methods.
Syntax
The syntax of the interface
access- modifier interface <interface_name>{ //variable and method declaration }
Example of interface
interface students{ int AGE=23; void eat(); }
Program
interface college{ void study();//method definition } class school implements college{ public void study(){ System.out.println("Hello I am a student"); } public static void main(String args[]){ school obj=new school(); obj.study(); } }
when the above code is executed, it produces the following result
Hello I am a student
There are other Java language keywords that are similar to this keyword
static keyword in Java language
Suggested for you
Usage of final keyword in Java
How to find reverse number using method In this article, we will discuss the concept…
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…