The interface keyword in Java language
- Home
- Keyword in Java
- The interface keyword in Java language
- On
- By
- 0 Comment
- Categories: Keyword in Java
The interface keyword in Java language
The interface keyword in Java language
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
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