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

extends keyword in java

implements keyword in java

 

 

 

Suggested for you

Interface in Java programming language

 Java language Keywords

C language Keywords

 Python language Keywords

 

 

The implements keyword in Java language
The byte keyword in Java programming language
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Share
Published by
Karmehavannan

Recent Posts

PHP Star Triangle pattern program

PHP Star Triangle pattern program In this tutorial, we will discuss about PHP Star Triangle…

1 month ago

PHP Full Pyramid pattern program

PHP Full Pyramid pattern program In this tutorial, we will discuss about PHP Full Pyramid…

1 month ago

5 methods to add two numbers in Java

5 methods to add two numbers in Java In this tutorial, we will discuss the…

2 months ago

Python Full Pyramid star pattern program

Python full Pyramid star pattern program In this tutorial, we will discuss  the concept of…

5 months ago

Write a function or method to convert C into F -Entered by user

Write a function or method to convert C into F -Entered by the user In…

9 months ago

How to write a function or method to convert Celsius into Fahrenheit

How to write a function or method to convert Celsius into Fahrenheit In this tutorial,…

9 months ago