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

public Key words in Java

static keyword in Java language

Volatile Keyword in Java

Transient keyword in Java

Package keyword in Java

class keyword in Java

boolean keyword in Java

break keyword in Java

do keyword in Java

double keyword in Java

This keyword in Java

final keyword in Java

switch keyword in Java

 

Suggested for you

 Java language Keywords

C language Keywords

 Python language Keywords

keywords in C language

Usage of final keyword in Java

Usage of this keyword in Java

 

 

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.

Recent Posts

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago