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 pmnice explanation .Can u tell me how can we instantiate Abstract class
Alps on February 7th, 2012 3:46 pmNo, you cannot instantiate an abstract class. An abstract class is a class that is not yet “finished” – it contains methods without an implementation. A non-abstract subclass is supposed to implement those methods
You can create anonymous subclasses that implement all abstract methods:
AbstractAction action = new AbstractAction(“Hello”)
{
public void actionPerformed(ActionEvent e)
{
// this is the only abstract method in AbstractAction
}
};
These anonymous subclasses only support the constructors of the abstract class though, you can’t create your own ones. If you need that kind of behaviour you need to create actual subclasses
Bhaskar on February 8th, 2012 6:53 pmJoe, Can you please re-design the site to help the user to reply to a specific comment, rather than commenting in end.
It would help people in following better, to the question/tips left by fellow contributors
Java Learner on February 8th, 2012 6:56 pm@Java Learner, yes I need to make that change so that we can reply to a particular comment. Sure I will do it as soon as possible.
Joe on February 8th, 2012 9:34 pmtheoritically good .try to show it with examples….
Swami on February 10th, 2012 12:21 pmThanks a lot !!!!!!!!!!!!
prakash on February 15th, 2012 11:42 amis very useful for my exam preperation
Thanks again
Thank u very much…… this explanation is short pls put more anyway thanks guyz
appu on February 15th, 2012 7:18 pmsuch a nice example for prepare an interview
Reshma on February 16th, 2012 4:17 amHi all,
Aricent on February 16th, 2012 1:15 pmI came to know that most of you are clear with the differences. Can anyone of you explain this point,“In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.” Even i read in several sites interfaces require extra indirection and hence slow. why is it and what is indirection,
nice one but give one example
shiva on February 17th, 2012 12:45 pmwhen we use abstract class? and when we use interface? pls reply
javabean on February 23rd, 2012 12:34 amCan you please explain with an example for both abstract and interface? It is very useful and easily understand
Anonymous on February 25th, 2012 6:32 pmthanks man u are great!!
Anonymous on February 25th, 2012 8:14 pmperfect….dude….
Anonymous on February 26th, 2012 8:05 pmwhen do we use interface and abstract class ?? what is the necessity of using both of them differently if they are similar to each other ?
Manoj Singh on February 29th, 2012 8:03 pmwhere should we use interface and Abstract?
karthik on March 7th, 2012 4:53 pmare you alive
Koray on March 10th, 2012 5:31 amgrt site.
Anonymous on March 12th, 2012 6:47 pmthanks for yr dis ans………
kiran on March 13th, 2012 3:56 pmPlease let me know how the abstract class is faster than interface
ravi on March 14th, 2012 9:11 amVery helpful site. Will share it on facebook :)
Anish on March 14th, 2012 10:25 amInterface Requires more time to find the actual method in the corresponding classes.
Bimal Modak on March 14th, 2012 7:52 pmthis is why Abstract class implementation is faster than interface
abstract class does not have a body
lalit on March 15th, 2012 3:27 pmsometimes a problem occurs where we have to only define methods in abstract class,but using only methods in a class is against an Object-oriented concept.that is the reason we use interfaces..because interface is not a class so we can easily put methods in an interface.
chirag pandey on March 16th, 2012 10:06 amwhy we use interface or abstract class and what is the best approch interface or abstract class
pawan kumar on March 20th, 2012 11:03 pmThis is really useful
amit on March 23rd, 2012 11:20 amThanx a lot
jasmy jose on March 23rd, 2012 8:58 pmplz send me some java course materilas, i am learning initial stage and i need not take any training, i have learn java my own thats why please send me some course meterial that materials useful my starting stage.
plz avoid authors books
Srinivasulu on March 24th, 2012 4:15 pmIs 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;
/**
Sanjay Patel on April 2nd, 2012 9:56 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();
}
}
Thank u for useful information
Sakthivel on April 5th, 2012 3:23 pmCan we extends the interface ? if yes then show me by one example if no then tell me a proper reason ?
Mayank on April 5th, 2012 7:49 pmthanks
aashraye rai on April 6th, 2012 6:55 pmThank you for giving the nice info….
Susagar on April 7th, 2012 7:08 pmits a useful tutorial
seenu on April 12th, 2012 5:05 pmits a useful tutorial
seenu on April 12th, 2012 5:05 pmthanks for giving valuble information…….. friends please send some more java material to me my e-mail is:govind.588@gmail.com
Anonymous on April 14th, 2012 12:02 pmThank you for providing us these answers
Jzeet on April 15th, 2012 11:32 amif any interface is enxtend the same abstact method with in the abstract class then what will happen……. how? please send me one example////
Anonymous on April 17th, 2012 2:45 pmWhat is the significance of Interface?
Its just a declaration of method names. But the implementation is still in the class.
Any one can answer?
Francis on April 23rd, 2012 1:30 pmjoe .plz explain
Ajay Patil on April 25th, 2012 6:26 pmhow transient keyword works with small example and what do u mean by serialization
hi joe
anu on April 26th, 2012 10:38 amcan i know exact usage of both interface and abstract class?
hai joe sir,
Iam a begginer in java,before reading this blog i had lot of confusions in my mind now I got clear idea about interface and abstraction.Thank you so much for that……can you plz include some examples(programm).
Biji A
Anonymous on April 27th, 2012 10:36 amNice blog:)
josh on April 27th, 2012 4:30 pmhi Guys ……
My Question : Can Over riding supports Inner classes in java?
package com;
public class Test
{
public static void main( String[] args )
{
A b = new B();
System.out.println( “Calling b.test(): ” + b.test() );
B b1 = new B();
System.out.println( “Calling b.test(): ” + b1.test() );
}
private static class A
{
public static String test() { return “A”; }
}
private static class B extends A
{
public static String test() { return “B”; }
}
}
if you need any help in java … contact me …
siddardhas@yahoo.co.in
sid on April 28th, 2012 1:45 amexamples are good for me……*
avdhesh samele on May 1st, 2012 1:25 pmnice blog..
Munna on May 3rd, 2012 1:16 pmthanks
priti on May 8th, 2012 3:42 pmnot bad
Anonymous on May 8th, 2012 11:22 pmpls include some examples
Bala on May 9th, 2012 8:48 amthank u…
Anonymous on May 14th, 2012 10:36 amThanx for difference …
Akshit on May 14th, 2012 2:38 pmit is help me lot in tomorrow exam of java ….
thanks…It is very useful….
SANKARGANESH L on May 16th, 2012 9:29 amthanks a lot it is helpful for my exam
imran on May 17th, 2012 1:04 pmCould you Please Explain Difference Between Interface and abstract class with real time example?
Nagarjuna Reddy.M on May 18th, 2012 5:53 pmi think 5 point i have doubt
malli on May 24th, 2012 12:01 ammalli,
“i think 5 point i have doubt”
coming to your Qestion
Class A extends Class B(abstract class)
{
// Class can extend only ONE Class
}
Class A implements Interface A, Interface B, Interface C {
//Where as Class can implement Multiple Interfaces
}
Hope you are clear now
Srikanth K on May 24th, 2012 10:43 pmhi, sir
i have recently complete my MCA and Join a company as java programmer, but i dont have knowledge of java, and i dont have much time to join coaching, so is there a way to learn java pls suggest me some sophisticated way to learn java programs…..
pramod on May 25th, 2012 12:21 amGood initiation
sudhir on May 28th, 2012 1:42 pmVery useful and very clear. Thanks.
Farhan Munir on May 30th, 2012 7:35 pm1 more diff=
Vijay on May 31st, 2012 1:38 amAn interface cannot have a constructor whereas an abstract class can have a constructor which is called indirectly by the derived class.
Good
ertet on May 31st, 2012 11:16 amits good
anand on May 31st, 2012 12:02 pmits very useful for all.
ram on May 31st, 2012 12:04 pmthanks
hmmm have to improve
Anonymous on June 1st, 2012 11:50 pmhmmm have to improve
Sreejith on June 1st, 2012 11:51 pm