Skip to content
October 29, 2008 / Narayan

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.

public interface testInterface {
//one of the method without method body
void disp(String text);
}

For implementing this interface through normal class we follow below step:

	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");
        }

}
Advertisements

2 Comments

Leave a Comment
  1. EJP / Jun 9 2009 4:07 am

    > 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.

  2. Narayan / Jun 9 2009 11:18 am

    it was just my though

    i’ll elaborate it…….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: