23/04/2008
- Main difference is methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behavior.
- Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.
- Members of a Java interface are public by default. A Java abstract class can have the usual flavors of class members like private, protected, etc..
- Java interface should be implemented using keyword “implements”; A Java abstract class should be extended using keyword “extends”.
- An interface can extend another Java interface only, an abstract class can extend another Java class and implement multiple Java interfaces.
- A Java class can implement multiple interfaces but it can extend only one abstract class.
- Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.
- In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.



















5. An interface can extend another Java interface only [...]
It sounds like what you’re saying is that an interface can
mjt on December 17th, 2009 10:03 amONLY extend ONE other interface?
No, an interface can extend multiple interfaces.
Probably I should have phrased difference 5 as, “an interface can extend other interfaces and cannot extend an abstract or concrete class. Also, an interface cannot implement (but extend) other interfaces”.
Thank mjt for pointing out.
Joe on December 19th, 2009 2:47 pmthanks for the abstract and interface difference ..
zelalem on December 19th, 2009 8:10 pmplease send this complete book for me
if interface object’s initialization with corresponding class instantiation examples would have presented.
Balraj kairamkonda on December 25th, 2009 11:54 amInstead of picking points from Java books about the differences, it would be better if you describe the main advantages of using interfaces and abstract class, when to use interface and abstract classes. That would add value to your question and make easy understand to the viewer.
Unknown on January 4th, 2010 10:52 amExcellent tutorial on abstract and interface difference
Anonymous on February 11th, 2010 12:41 pmOne more point – If I dont want multiple inheritence then which one is better to use?? Interface or abstract class??
@unknown – I was just trying to reproduce the theory in a simple way as in my style.
But, apart from this list of difference, I will write a separate article on when to use interface and when to use abstract class
Joe on February 12th, 2010 6:00 amThe difference no 8.
“In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.”
What is this “extra indirection”. I have seen same difference point in other sites without clear information.
Also how can we prove that java interfaces are slow than abstract classes.
Arun Pratap Singh on March 6th, 2010 8:43 amto know more about the difference between interface and abstract class ….read SCJP kathy sierra’s book….best as far as i know…
rakesh on March 9th, 2010 10:50 amgood i learn very much from this webiste
abubakar on April 27th, 2010 8:00 pmthanks for giving explanation and difference between these two and i need more details about core java
rajesh on July 28th, 2010 11:12 amHi,
Sean, melbourne photographer on August 1st, 2010 12:38 pmsome nice tips on this site!
I also don’t get difference 8 though – can you clarify please?
how to utilize interface in another class without implementing that interface
raghu on August 3rd, 2010 2:34 pmIt’s good, lists the complete abstract and interface difference in simple way
Argha Basu on September 16th, 2010 2:16 pmHey Raghu,you can do that by making the implementing class abstract and then extend it in another class of your choice .
maxmetallica on September 24th, 2010 6:31 pmapart from difference between them,
Manish on October 28th, 2010 11:08 pmuse Interfaces when you require 100% abstraction otherwise use abstract class
Why interface cannot be instantiated?
Manas on November 7th, 2010 7:19 pmwhy a default constructor is provided by jre in java
prateek srivastava on November 24th, 2010 11:59 amthanx for the complete abstract and interface difference thing… its good, it helps me alot
monika bansal on December 5th, 2010 4:15 pmYour website looks so good..
Hema on January 24th, 2011 8:47 amHi,
We can also discuss like an interface will be used for an object reference of its implementing class while abstract class object reference can be used for its extending class.
subbu on January 25th, 2011 4:34 pmyour explanation is very good
mohan on January 31st, 2011 5:45 pmplease send me the whole book
There is no book. But I have an idea of coming up with something in the future.
Joe on February 1st, 2011 3:40 aminterface is the most powerfull solution of using multiple inheritance because java does not support multiple inheritance
Thank you
yogesh on February 5th, 2011 5:58 amgood explanation but
rajesh on February 5th, 2011 1:33 pmexplain new topics on java
Thank you…very much……..
amit kumar on February 13th, 2011 5:06 pmplease…..
send me one copy of this book.
ya i accepted this concepts and more useful for beginers……..
niyaz on February 21st, 2011 10:58 amHi.
can u give me the difference between the two following statements
1.A sub1=new B();
2.B sub2=new B();
where A is suerclass
B is the sub class
//method over riding
class A
{
int i,j;
A(int a,int b)
{
i=a;
j=b;
}
void show()
{
System.out.println(“super”);
System.out.println(i);
System.out.println(j);
}
}
class B extends A
{
int k;
B(int a,int b ,int c)
{
super(a,b);
k=c;
}
void show()
{
System.out.println(“sub”);
System.out.println(i);
System.out.println(j);
System.out.println(k);
}
}
class Override{
public static void main(String args[])
{
A sub1=new B(1,2,3);
B sub2=new B(1,2,3);
sub1.show();
sub2.show();
}
shafi on March 3rd, 2011 6:37 am}
first you have to concentrate on Polymorphism concept , why because if you are crating the object and the object reference is give to super class , then on that time it checks whether that method is there in subclass or not at compile time
venkat on March 3rd, 2011 3:43 pmplz write a default construcctor in side class A then above code compile and run successfully………..
Chandrashekhar on March 21st, 2011 7:44 amexample is nothing but a polymorphism………
Chandrashekhar on March 21st, 2011 7:45 amthanks it is very useful.
sindu on March 23rd, 2011 3:44 pmthanks for clarrification
ramakrishna on March 25th, 2011 12:48 pmWhen to use abstract class over Interface ?
Thanks in Advance
Remya on April 1st, 2011 7:05 amRemya
its a great help for understanding main difference between both abstract class as well as interface.
Aryan Nardiganj on April 17th, 2011 7:48 pmto know more about the difference between interface and abstract class ….
plz mail me the difference in abstract and final keywords in java
manish on April 19th, 2011 4:30 pmwhat is difference between overloading and overriding?
vivek kumar on April 27th, 2011 2:09 pmWow… it is too good Blog..
it is too Elegant..,
Conceputally Nice…,
I like the Way u explain about “Difference between Abstract class and Interface”
What my suggeation is…, Write one Example Program For Every Explanation..
RaamNaresh Reddy on April 29th, 2011 5:50 amthanks for ur explanation
Thadeuse on May 1st, 2011 4:13 amis it possible
Thadeuse on May 1st, 2011 4:30 amabstract class A extend b implements c
{
}
thanks for explain it
trupti on May 7th, 2011 10:50 amthanks for the basic help in java
Uma Karmakar on May 12th, 2011 8:13 amHow many maximum number of Interfaces are implements in our class?
Hari chowdary on May 14th, 2011 7:11 amHi….. It is too good.
Rahul Jaiswal on May 27th, 2011 9:21 amHi Joe,
meena on June 2nd, 2011 1:31 pmThis is very useful.Being a fresher its very useful for me. Mainly the website design is really fantastic.Keep going……….
why abstract class does not support for the multiple inheritance?
sam on June 6th, 2011 11:15 amPlease mail me this book.
Asha.BM on June 7th, 2011 2:18 pmThanking U for providing a comprehensive information. may allmight with u to have ur destiny.
Lokanath on June 7th, 2011 6:55 pmhai
rajitha on June 9th, 2011 8:18 amvery nice and good.
Thanks it was a little helpful for me….
Zeeshi on June 13th, 2011 5:08 pmDifference B/W overRiding and overLoading:
in over riding perameters and type of method remain same. but its internal properties changed you can say over ridden.
in over loading the name of method is same but parameters are different. according to type or in number. the call to these functions depends on the parameters compatibility…
Zeeshi on June 13th, 2011 5:12 pmdis infermation is very well and easy to understanding…..i am feel good………
kousalya on June 16th, 2011 6:27 amthe main difference is interface doesnot talks about implementation.it talks about requirement specification
guest on June 17th, 2011 5:45 amabstract class:
it talks about implementation but not completely(partial implementation).
Hi readers,
satnam singh on June 17th, 2011 7:15 ami go through all above mentioned discussion regarding interfaces and abstract classes. So i feel some person need example where to use interfaces . In order to understand the interface concept just thinking that how jdbc api worked with each and every dbms(oracle,mysql etc) because jdbc api provide just interfaces and implementations of these interfaces are provided by the dbms vendor that implementations are known as database drivers. (9888327755-ssubhi_2003@yahoo.com). Feel free to discuss any java topic
thanks
dis infermation is very well and easy to understanding…..i am feel good………
Rajanikanth on July 2nd, 2011 5:50 pmwell written
Mansi Singhal on July 6th, 2011 4:54 amEasy and point wise description help me to understand the exact difference.
Kavan Vakhariya on July 12th, 2011 10:44 amIm ery helpful to all, this discussion has provide me clear knowledge.
Anonymous on July 15th, 2011 6:23 amyes and i most lke info provided by satnam singh, you know we were using that but never came in mind that how basic java get used over there. great….
nice artiacle and very helpful also…Can anybody explain why java interfaces are slow and how it requires extra indirection??
Thanks in advance.
Guest on July 19th, 2011 6:08 amAll the above mentioned pts. are totally easy to undertand.
Madhuri Gorde on July 21st, 2011 6:13 amhii can any one help me to know how interface is slower than abstract abstract class.
ganesh on July 21st, 2011 10:30 amin the above article what indirection means?
Really nice points to understand thanx
arxlan ahmed on July 21st, 2011 10:56 amCould you please give some program examples, about their diffrences
Swetha N on July 23rd, 2011 9:00 amhi i through all above ur’s feedback pls can u people send me what is difference between class interface and abstract class
krishna on July 25th, 2011 5:47 amsend me j-krishna@live.com
how multiple interface is used instead of multiple inheritance??
kasthuri on July 26th, 2011 9:30 ambefore studying this information i am not clear about interface and abstract class.just now i am know about this topic.thank you
venkatesan.g on July 28th, 2011 11:22 amNeat & Clear!!! Information provided can be understood by even a average student.
Yashas on August 3rd, 2011 12:56 pmi need a difference between a class and a interface?
Anonymous on August 6th, 2011 2:14 pmVery well written article
Rajesh Kumar on August 8th, 2011 6:46 amAll of the variables in an interface are implicitly static and final.
Justin on August 16th, 2011 4:54 pmhai guys, how to use in spring with struts?
kathirvelan on August 22nd, 2011 10:22 amnice info
ppp on August 26th, 2011 12:16 pmthanxxxxxxxxxxxxxxxx
Deepak on September 5th, 2011 10:17 amall i saw was jibber man.. please for heavens sake , use examples…!
wtd on September 6th, 2011 5:50 amnice explanation
vijayPratap Singh on September 7th, 2011 4:39 amnice explanation
vijayPratap Singh on September 7th, 2011 4:39 amMr. Satnam Singh explained very well…..so nice
Sayyed Imam on September 11th, 2011 1:14 amthats good, i understand the difference between interface and abstract class.
Jeetu on September 14th, 2011 4:00 ambut can you give a code which show the difference ……
Easy to understand
Anonymous on September 14th, 2011 8:27 amits very helpful to me thanqs for your kindly info…….
srikanth venigalla on September 17th, 2011 8:31 amits very help to me .thanqs fro your kindly info…
srikanth venigalla on September 17th, 2011 8:33 amnice difference between interface and abstract class
mohit on September 22nd, 2011 6:41 pmi have a doubt, if we implement an interface need to write all the methods in that interface even if we don’t need the methods .what is the case of abstract class?
shree on September 23rd, 2011 9:11 amThank you all for your great comments!
Joe on September 26th, 2011 4:29 amthanxxx
ankit on September 26th, 2011 2:09 pmplz send me the complete tutorials so that it will helps me a lot
T.PRIYDARSHINI on September 29th, 2011 4:31 amThank you so much for giving the best Answer…
because of i am so confused
Pankaj on October 6th, 2011 6:54 amThank you again.
abstract class and java class both are same or different???
T.PANDEESWARI on October 7th, 2011 6:06 amHI Joseph,
Let me know that why we are choosing “Interface” & “Abstract class” for a good application..
Thanks in advance,
Selva on October 7th, 2011 7:39 pmSelva
hiiiiiiiiiii joseph,
what is we commoly use in java project that is absruct class or interface?
my second question is that what the actuall meaning of implimentation and extand?
neeraj tanwar on October 10th, 2011 5:57 ammy first ques is 1)6 points of difference between object and class.
ruchi on October 12th, 2011 5:28 pm2)6 points of difference between dynamic binding and message passing.
ques) explain briefly why cant we use a keyword as a variable name???
ruchi on October 12th, 2011 5:30 pmtell me true or false…
ruchi on October 12th, 2011 5:33 pm1. when if statement are nested,the last else gets associated with the nearest if without an else.
2. one if can have more than one else clause.
3. a switch statement can always be replaced by a series of if…else statements.
4. a switch expression can be of any type.
5. a program stops its execution when a break statement is encountered.
very very good explanation on the differences
manas sahoo on October 15th, 2011 11:32 amThis is quiet good….
VipinJeet Tripathi on October 16th, 2011 3:29 amIt may be useful for interview…
very accurate answers.good.
sushil on October 16th, 2011 12:47 pmvery nice answers good
harshil on October 16th, 2011 2:03 pmThis is really good….
soma on October 17th, 2011 1:28 pmIt is useful for interview
Its so easy to learn even if the people doesn’t know java
Rajan E on October 18th, 2011 6:47 amtt
tt on October 18th, 2011 7:23 amThis is really helpful!!
Samantha on October 19th, 2011 5:00 amHi Joe,
Can you please tell me when to use Abstract class and when to use Interface in an application?
Shitansu on October 19th, 2011 7:25 amgive reallife example of interface…….
vinod on October 19th, 2011 7:28 amhey i didnt get my answers,,,,,,,,,,,,
Anonymous on October 20th, 2011 3:58 pmthank u sir
plz mail me similarities between an interface and classes
khushboo on October 21st, 2011 1:41 pmIn interfaces we cannot have any implementation for methods but that’s not the case with abstract classes we can have implementation for methods.
jessie143143 on October 21st, 2011 2:21 pmthank you for giving informations
mani on October 25th, 2011 6:02 ambut i want more details …..
nice explanation for interface and abstract class
ramesh on October 30th, 2011 9:11 amabout java buzz words ?
sampath on November 2nd, 2011 12:27 amIt is very use full for me….. Thank you… by V.Vinoth from poondi
vinoth on November 2nd, 2011 4:41 amThank you very much … it was very useful to me
Ahmad on November 2nd, 2011 7:14 pmthank u for giving this wondarful information
sai on November 4th, 2011 12:52 pmHi Joseph sir,
Thanks for the detailed explanation of diff between abs class and interface. I would like to know , on what basis programmer deside he need to use interface or abstract class ? and if interface is having 2 abstract methods(only) and abstract class is having 2 abstract methods(only) then what was the difference in both ? Please post answers for the questions.
Praveen on November 5th, 2011 11:00 amThanks and Regards,
Praveen G
Very helpful…
Anudeep on November 5th, 2011 9:28 pmplz give me the 6 points of difference between messege passing and message binding……..
karabi das. on November 10th, 2011 5:57 pmi still have a doubt, when we have to use interface and when we have to use abstract(class as well as method)
srividhya on November 16th, 2011 7:28 amplz suggest me how can i become expert in making programs by myself?? because coding postion in java is a biiiiigggg giant for me can u suggest how can it be easier for me the coding in java
ana on November 19th, 2011 7:37 amnice web site
swati on November 19th, 2011 8:56 amits really helpfull for my class lacture
sabrina on November 21st, 2011 5:25 amwhat is the main reason to create abstract class?…..
mayank jain on November 21st, 2011 11:43 amsir i know we cant create object of abstract class and we also provide method body in abstract class compare to interface…
good and simple
Anonymous on November 23rd, 2011 5:18 amdifference b/w instance variable and class variable.
Anonymous on November 23rd, 2011 11:57 pmwhat are the changes to a variable ,method and a class when a final keyword is added to them.
jangbahadur patel on November 24th, 2011 12:03 amI was put forth this question in the interview.Please help.
When you have to pass the data in the form of keys which collection would you use ?
jayashree on November 26th, 2011 1:38 pmthank you for information about abstact class and interface
Thirupathi on November 30th, 2011 10:39 amApart from these differences one more difference is in my mind, i want to ask is it correct or not-
* interface can be declare as a member of a class while abstract class is’t.
ram kumar on December 3rd, 2011 6:19 amsome interface define just constants and no methods……thanks 4 giving such simple and good differences….can u send me whole book on my given id….plz…..
vivek bhatt on December 6th, 2011 6:17 amcan u send me the real time example that when do we use interfaces and when do we use abstract class
Mahesh Reddy on December 7th, 2011 6:21 pmIts very easy and useful to me
samson on December 8th, 2011 8:53 amOne more point:
1. If we created Interface we can add new methods easily, but abstract is not easily.
2. Interface act as Service layer its interact different types of two entities(node) but abstract is not.
3. Interface is high level of abstraction(fully abstract class) but abstract is next level of abstraction.
I have added some point. Please verify and let me know if it is correct or not?
Please forgive any typical and grammatical mistake.
Please send me if any feedback: murugadoit@gmail.com
Muruga G on December 18th, 2011 7:55 amTake all :)
santosh on December 20th, 2011 9:25 amAbstract class start with letter “A” and Interface starts with letter “I”.
Arabinda on December 20th, 2011 9:45 amWhat is the purpose of using Abstract class????
Shaleen on December 23rd, 2011 6:15 amHi,please provide the Real-time examples for Interface and the Abstract class.So that every one can understand easily..
Jayaram on December 24th, 2011 4:21 pmHi Joe ,
Balachandiran on December 25th, 2011 6:46 pmwhen we have to use abstract class & interfaces can you explain
If i create any reference variable to an interface and also i create the object of implementing the class.just mail me the difference
mallika.oleti@gmail.com on December 27th, 2011 3:02 pmHi Joe,
First of all its a nice blog. Congrats for writing and maintaining this blog.
On Dec 19th you have mentioned that “an interface can extend multiple interfaces”.
But java doesnt support multiple inhertance. Please explain your statement.
With Regards
shiv on December 29th, 2011 12:35 pmShiv
thanks joe for detailed explanation
maagi on December 30th, 2011 12:53 amgood explanation
Vijay Yatham on December 30th, 2011 4:46 amHi All,
I am new to java. Can you please explain what are the topics covered in J2EE? if i want to serve in Java field, what are all i need to learn..
Please help me.
Rajesh on January 3rd, 2012 9:49 am-Thanks in advance
Hi All,
I am new to java. Can you please explain what are the topics covered in J2EE? if i want to serve in Java field, what are all i need to learn. and also please explain the ways
Please help me.
Rajesh on January 3rd, 2012 9:50 am-Thanks in advance
what if abstract class implements two interfaces then it has to provide bodies for method declarations in interfaces or not?
Sandesh on January 4th, 2012 5:43 amwhen we have to use abstract class & when we have to use interfaces can you explain
Anonymous on January 5th, 2012 6:24 amThank you,that the difference between them is clearly understood to me.Please explain in simple programatic way?
when we have to use abstract class & when we have to use interfaces can you explain?
bharath on January 5th, 2012 1:37 pmThank you for clearing doubts…..please send this book to my mail id…i have some more doubts
vishnugandhi on January 10th, 2012 12:04 pmThis differences can be found everywhere, say new things like
1. when to use Interface and when to use Abstract class
2. which one is efficient ?
Just give some practical programming scenarios.
Venkatesh Bestha on January 10th, 2012 5:09 pmhello nyc blog
Anonymous on January 11th, 2012 10:39 amhiiii gud source of info……keep goin!!
keith on January 11th, 2012 10:41 amhello
keith on January 11th, 2012 10:42 amcatch
Anonymous on January 11th, 2012 11:07 am{quotient=divide(num1,num2);
cout<<"The quotient is "<<quotient<<endl;
}
try(char *exceptionString)
{
cout<<exceptionString:
}
wat is the error in this code……..
Thank you sir it is really helpfull to me keep going on………..
rajesh on January 12th, 2012 11:08 amThanks a lot !!!!!!!!!!!!
you are The Best.
Thanks for writing and maintaining this nice blog. this is very nice blog.
pranav thipse.
Pranav Thipse on January 13th, 2012 5:22 pmHi Sir, really good blog.Very much impressed by the blog and the information displayed.It would be nice if you can start covering advanced topics also in this blog.
Sujay on January 18th, 2012 2:38 pmHi joe,
Kiran on January 19th, 2012 3:36 pmI know about Interfaces & Abstract classes. But can you please let me know why there are 2 different things Interface & Abstract class. When only Interface was enough(I guess, to do all the work.)
i stil hav a lot of doubts.can u jst giv some example and also show whn to use wht?
pritz on January 19th, 2012 8:18 pmit was really nice and in a very simple language… thanks joe
Anonymous on January 19th, 2012 10:49 pmcan any1 give me A simple program for managing abstract and interface which includes all aspects as joe said?
saravanan on January 21st, 2012 2:54 pmcan any body explain me constructor in detail…i don’t no the use of it pls. explain me..
neha on January 21st, 2012 8:02 pmThanks joe really helpful,But I’m having confusion about the term “extra indirection” used in 8th difference can u please explain what it is ?
siddu on January 24th, 2012 10:40 amI have a doubt Joe,
In my current coding, my aim is to call the same method in different classes simultaneously. say class1 and class2 access add()method present in class3. My issue is a null pointer is getting displayed on execution. Can u guide me on this???
indian freak on January 24th, 2012 12:48 pmcan you please explain how the servlet communication done to other? explain different ways ?
yogesh on January 24th, 2012 2:46 pmThanks you for giving to this this answer.
Anonymous on January 29th, 2012 11:19 amSome simple examples would be really great :)
pazuzu on January 30th, 2012 10:26 pmthis is awesome. thanx
Anonymous on February 1st, 2012 12:53 amPlease any one explain ,where we use Abstract calss and where we use interface .
Anuj on February 1st, 2012 5:59 pmPlese give example
is an interface implicitly an abstract class?
Thanks…
Rajeev Kumar on February 2nd, 2012 12:41 pmNo. An interface is not an absrract class implicitly. Those two are interpreted in a different way.
Joe on February 2nd, 2012 7:27 pmGood one. I had a look at the following website. that too looks good.
https://www.logicsmeet.com/forum/23488-Difference-Between-Abstract-Class-and-Interface-in-.NET.aspx
Balaji on February 2nd, 2012 8:49 pmany book to get a good knowledge of java in simple and easy text?
Anonymous on February 2nd, 2012 10:16 pmhi thanks for differences of abstract and interface .please send the complet book to my mail id are the address in url pattern (rakesh.gandua9@gmail.com)
rakesh on February 3rd, 2012 12:44 pmhiii,,,,thanku for u r description plzzz send the java book which can be helpful in the basics point of view to my email id (kalyaniapple93@gmail.com)
Anonymous on February 3rd, 2012 6:05 pmIn the 7th difference pls give an example that how can we invoke abstract class if main exist…
navi on February 3rd, 2012 8:24 pmpls send the best book for core java to my mail id i.e. anjaniatmakuri@yahoo.com
anjani on February 3rd, 2012 8:27 pmNice work again…but i don’t understand 7th difference,can u explain me in detail.
Matheen on February 5th, 2012 1:43 amIs it possible to implement Iterator interface
Methods in our own class?
for example
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Collection;
/**
Arjun on February 5th, 2012 11:57 am*
* @author arjun gm
*/
public interface java.util.Iterator {
public abstract boolean hasNext();
public abstract E next();
public abstract void remove();
}
public class MyInno implements Iterator {
boolean hasNext()
{
System.out.println(“Add”);
return true;
}
void remove()
{
System.out.println(“Sub”);
}
public static void main (String args[])
{
MyInno my=new MyInno();
my.remove();
}
}
why variables declared in interface are final by default and why all members are public by default?
when and where interfaces and abstract class is to be use?
Thanx…..
Musaddiquie Husain on February 6th, 2012 11:35 pm