Java interface

23/04/2008

A java class containing all the methods as abstract is called an interface. A method that has no implementation and which is expected to be implemented by a subclass is called an abstract method. Java interface can contain constants. When an interface needs to be instantiated it should be implemented by a class and all its abstract methods should be defined. If all the methods are not implemented in the class then it becomes a java abstract class and so cannot be instantiated. Variables declared in a java interface by default is final.

is there other methods then abstract methods? would public, private, protected be another example of methods?

Anonymous on January 28th, 2011 4:25 pm

Hello Sir,
It’s all blogs are great. I have really got amazing information through this blogs would you please add some questions regarding to Struts and Hibernate. It will be really helpful.

Thanks again for all blogs….

Regards
Vishal S. Pawar

Vishal Pawar on April 15th, 2011 5:48 am

[...] an adapter is the travel power adapter. American socket and plug are different from British. Their interface are not compatible with one another. British plugs are cylindrical and American plugs are [...]

Adapter Pattern&hellip on May 7th, 2011 7:03 am

[...] start with an interface which creates a blue print for the class which will have decorators. Then implement that interface [...]

Decorator Pattern&hellip on May 17th, 2011 12:04 am

it is wonderful but give some examples

Anonymous on January 20th, 2012 10:08 am

give some examples sir

pavan on February 17th, 2012 1:12 pm

interface I1
{
void show();
void display();
}
class A implements I1
{
public void show(){System.out.println(“Hi”);}
public void display(){System.out.println(“Friend”);}
}
public static void main(String [] args){
A o=new A();
o.show();o.display();
}
}

Probleam: Multiple inheritence concept ignore this case.why interface used? Bcoz declare two methods declare in interface and a class define those methods.if this class remove line Implements I1 then also class just same work .Then this case what benefits of used interface????

Plz tell me extra benefits of interface used (concept multiple inheritence exclude)

Arun Ruhela on March 27th, 2012 12:14 pm


Email:

about
I am Joe, author of this blog. I run this with loads of passion. If you are into java, you may find lot of interesting things around ...more about me. Google+
java badge
Home