Interface Class

Actually Interface are just like a class where it consists only constants and they
We can extend interface via interfaces
We can implement the interface via classes.
In interface needn’t use the “public” or “abstract” keywords – all methods
declared by an interface are automatically public and abstract by default.
A simple example of interface implement is given below.
[sourcecode=’java’]
public interface testInterface {
//one of the method without method body
void disp(String text);
}[/sourcecode]
For implementing this interface through normal class we follow below step:
[sourcecode=’java’]
public class Grading implements testInterface{

//Constructor
public Grading(){
}

//display method from interface
public void disp(String text){
System.out.println(“The input string is ” + text );
}
//main method
public static void main (String[] args) {
Grading g = new Grading();
g.disp(“Hello”);
}

}
[/sourcecode]

2 thoughts on “Interface Class”

  1. > It is possible when we use the static final keyword on creating variable
    Or without it, as these attributes are implicit inside interfaces. There is no point in writing pointless code.

Leave a Reply