Difference Between Interface and Abstract Class

  1. 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.
  2. Variables declared in a Java interface is by default final. An  abstract class may contain non-final variables.
  3. 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..
  4. Java interface should be implemented using keyword “implements”; A Java abstract class should be extended using keyword “extends”.
  5. An interface can extend another Java interface only, an abstract class can extend another Java class and implement multiple Java interfaces.
  6. A Java class can implement multiple interfaces but it can extend only one abstract class.
  7. Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.
  8. In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.
This Abstract and Interface tutorial was posted on 23/04/2008.
Ads by Google

516 comments on “Difference Between Interface and Abstract Class

  1. 5. An interface can extend another Java interface only [...]

    It sounds like what you’re saying is that an interface can
    ONLY extend ONE other interface?

    • Java interface inherits one or more than one interface using “extends” keyword.so we called java supports multiple inheritance using interface.

      • Interface can not extend multiple interfaces it implements multiple intefaces
        see the difference carefully.

        • Hello Govardhan,

          you are wrong.. interface can extend many interfaces.. while using classes alone interfaces should implement.. dont misguide people.


          • I verified. What Shaffic said was correct.

          • abstrat class are in java but why interduced interfacess.

        • Mr.Goverdhan,
          An Interface can not implements another Interface It’s implements by class.An interface always extends another interface like a class extends another class But a class can extends only a single class and interface can extends multiple interfaces at a time.

          • I Verified in my project what i working on currently. What Rajkumar Chaudhary saying is absolutely correct.

            public interface InterfaceC extends OnterfaceA, InterfaceB{

        • Please Remove Govindan’s comment. That wasted my 30 minutes.

          • hi
            same category of either class or interface use nly extend keyword.

      • hi Ansumalini Jena,
        An interface can only implements single or multiple interfaces.It can’t be extend.

        • sorry. An interface can extend single or multiple interfaces. Interface can’t be implements another interface.

        • Hi Panchanan,

          Sorry, but please refresh your concept. Interfaces always use “extends” keyword to implement interface(s) and not “implements”.


          • in interface must use implements becoz its an abstract.
            if use extends it shows error at run time

    • An interface can extend anoter interface
      but a class can implements any no of interfaces
      a java class can extend abstract class
      a java class can extend abstract class and implemnts any no of interfaces

    • can you tell me the situations when we should go for interface and abstract class….?

      • strictly when you want the method to common and use more as required then interface else




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

    • Yes,An Interface can extend one or more interfaces but it cant implement any interface

      • Is it possible

        public void abstract class Employee
        private String name;
        private String address;
        private int number;
        public void Employee(String name, String address, int number)
        System.out.println(“Constructing an Employee”);
        this.name = name;
        this.address = address;
        this.number = number;

          • No it is not possible because abstract class dose not have constructor.

          • Class declaration should not have return type.

          • Class should’n has any of return type… including void….

          • Abstract classes can contain constructors.

          • Constructor is a special kind of method inside a java class with the name as class name. It does return anything not even ‘void’.

          • how can a method be implemented within an abstract class…they can be implemented only by child classes…

          • Hi Moni,

            Can you please explain how a Java class Constructor will return. if we are putting any return type before constructor then that is not called as constructor that is called as user defined method. But you have mentioned that “Constructor is a special kind of method inside a java class with the name as class name. It does return anything not even ‘void’.”

            Here you have mentioned that It does return anything not even void. Can you please explain me this line what does this means. But i know if we are creating a constructor inside a class then rules is it should be class name and any access specifier but it doesn’t contain any return type. Like this Examples:

            class A
            public/private/protected A()

            Here class a contains one constructor which don’t have any return type.

            class B
            public void B()

            Here class B having two things one is default constructor provided by the compiler and another thing is that its contain one user defined method whose name is same as class name but not a constructor.

            So please explain your line.

            Thanks & Regards
            Sailendra Jena

          • I hope I’m not beating the dead horse here with my comments.
            Constructors are meant for initialization. That means, you can initialize your instance variables including final ones inside constructors. Constructors don’t return anything. For example:

            class Employee {
            private String name;
            private final Date hiringDate;

            public Employee(String name) {
            this.name = name;
            Calendar c = Calendar.getInstance();
            hiringDate = c.getTime();

            In the above example, I’m simply initializing the name with the param name and final variable hiringDate with the current date. Also, your final variables are assigned the values when the class constructor is called or class is initialized in the JVM. So a class constructor’s job is to initialize instance variables with their default or assigned values. They don’t return anything rather they reside in the JVM for as long as the object is alive.

        • “public void abstract class Employee”… what do you mean by void in class declearation

        • how a constructor can have return type?

          otherwise this is perfectly fine even abstract classes can have constructors. so its correct.

        • a class as well as a constructor can not have return type,even if not void

          • you are right for C++. In java, if you specify void, it will consider it as a normal method instead of constructor.

        • No,I think it won’t work as an abstract class cannot be instantiated..how this constructor can get executed…

          • It is valid. Here “public void Employee(…)” is a method which is having the class name but its not the constructor.

          • Abstract class can have constructor,we use it for varible initialization and also for constructor chaining.

        • it is not possible, b’caz class returning void,

          • constructor dose not have any return type,
            we can not create a object of a abstract class so how constructor will get called?

          • constructor dose not have any return type,
            we can not create a object of a abstract class so how constructor will get called?

          • constructor dose not have any return type,
            we can not create a object of a abstract class so how constructor will get called?

        • it is not possible because any class does not have any return type…

        • It wont work becoze its class and constructor have return type…which is not a valid,i think so…

        • The code is wrong because class cannot have return type void. If it is typed by mistake, than the code is perfect. If you write a method with the same name as class with return type it does not qualify as construtor. The compiler will concider it as a normal method. So the code is perfect. It can used by subclassing it and passing the arguments in method Employee.
          Hope it answers the query.

          • 1. class acn not be void.. its not allowed
            2. you can use a method with same as class name
            hence public void employee is ok
            3. you cannot create object of class employee as it is abstract class but calling private memer by this pointer is allowed …

            so finally just remove void from class declaration
            nd it will work ..
            just don’t create object and don’t try to invoke method :-)

        • yes!.. y nt. object class is der.. so it is true

        • ya friend this is possible.
          we can use of “this” keyword here.

          • I tried it, not possible haan

        • no because not hav return type of the class

        • public void Employee(String name, String address, int number)
          The abovecode is not constructor because it is returning void while constructor never return type..

          Anil Kesarwani

        • There should be at least one abstract method in the class

    • extends means one abstract class or one simple class

    • hi
      this not possible,because constructor not come return type and than abstract class there also no return type so this code is error

  3. thanks for the abstract and interface difference ..
    please send this complete book for me

  4. if interface object’s initialization with corresponding class instantiation examples would have presented.

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

  6. Excellent tutorial on abstract and interface difference
    One more point – If I dont want multiple inheritence then which one is better to use?? Interface or abstract class??

    • interface is better if you don’t want multiple inheritance because Because if you add new method headings to an interface, then all of the classes that already implement that interface will have to be changed to implement the new methods.

      • I think in this situation abstract class is better option.Becaause it is easy to add new functionality in abstract class and modify it in the child classes.but in case of interface u r bound to implement the methods in the class though ur classes dont need them.

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

    • I’ve been looking around but cannot find this newer article. Does it exist yet?

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

  9. to know more about the difference between interface and abstract class ….read SCJP kathy sierra’s book….best as far as i know…

  10. good i learn very much from this webiste

  11. thanks for giving explanation and difference between these two and i need more details about core java

  12. Sean, melbourne photographer said on ,

    some nice tips on this site!
    I also don’t get difference 8 though – can you clarify please?

  13. how to utilize interface in another class without implementing that interface

    • You have to define the interface from where you need the interface implementation ForEx. To write a thread program need to implement Runnable or to extend Thread .The other way is as follows .

      Runnable r = new Runnable(){

      public void run()
      //Do you thread code here
      new Thread(r).start();

  14. It’s good, lists the complete abstract and interface difference in simple way

  15. Hey Raghu,you can do that by making the implementing class abstract and then extend it in another class of your choice .

  16. apart from difference between them,
    use Interfaces when you require 100% abstraction otherwise use abstract class

    • we can not create instace of an interface because it hava incomplete methods. so can not provides sufficent memory by the jvm.

    • default constractor provided by compiler nor jre.

  17. thanx for the complete abstract and interface difference thing… its good, it helps me alot

    • In java all topic cover this site.

  18. Hi,

    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.

  19. your explanation is very good
    please send me the whole book

  20. There is no book. But I have an idea of coming up with something in the future.

    • The write up is really good..Were you able to book these?

  21. interface is the most powerfull solution of using multiple inheritance because java does not support multiple inheritance

    Thank you

  22. good explanation but
    explain new topics on java

  23. ya i accepted this concepts and more useful for beginers……..

  24. Hi.
    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)
    void show()

    class B extends A
    int k;
    B(int a,int b ,int c)

    void show()

    class Override{
    public static void main(String args[])
    A sub1=new B(1,2,3);
    B sub2=new B(1,2,3);


    • 1)it call the constructor of class B by passing the arguments(1,2,3) and it assign the reference variable of class A type
      2)it call the constructor of class B

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

  26. plz write a default construcctor in side class A then above code compile and run successfully………..

  27. example is nothing but a polymorphism………

  28. When to use abstract class over Interface ?

    Thanks in Advance

  29. its a great help for understanding main difference between both abstract class as well as interface.
    to know more about the difference between interface and abstract class ….

  30. plz mail me the difference in abstract and final keywords in java

  31. what is difference between overloading and overriding?

  32. Wow… 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..

  33. is it possible
    abstract class A extend b implements c

  34. How many maximum number of Interfaces are implements in our class?

  35. Hi Joe,
    This is very useful.Being a fresher its very useful for me. Mainly the website design is really fantastic.Keep going……….

  36. why abstract class does not support for the multiple inheritance?

  37. Thanking U for providing a comprehensive information. may allmight with u to have ur destiny.

  38. Thanks it was a little helpful for me….

  39. Difference 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…

  40. dis infermation is very well and easy to understanding…..i am feel good………

  41. the main difference is interface doesnot talks about implementation.it talks about requirement specification
    abstract class:
    it talks about implementation but not completely(partial implementation).

  42. Hi readers,
    i 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

  43. Easy and point wise description help me to understand the exact difference.

  44. Im ery helpful to all, this discussion has provide me clear knowledge.
    yes 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….

  45. nice artiacle and very helpful also…Can anybody explain why java interfaces are slow and how it requires extra indirection??

    Thanks in advance.

  46. All the above mentioned pts. are totally easy to undertand.

  47. hii can any one help me to know how interface is slower than abstract abstract class.
    in the above article what indirection means?

  48. Really nice points to understand thanx

  49. Could you please give some program examples, about their diffrences

  50. hi i through all above ur’s feedback pls can u people send me what is difference between class interface and abstract class
    send me j-krishna@live.com

  51. how multiple interface is used instead of multiple inheritance??

  52. before studying this information i am not clear about interface and abstract class.just now i am know about this topic.thank you

  53. Neat & Clear!!! Information provided can be understood by even a average student.

  54. i need a difference between a class and a interface?

  55. all i saw was jibber man.. please for heavens sake , use examples…!

  56. Mr. Satnam Singh explained very well…..so nice

  57. thats good, i understand the difference between interface and abstract class.
    but can you give a code which show the difference ……

  58. its very helpful to me thanqs for your kindly info…….

  59. its very help to me .thanqs fro your kindly info…

  60. nice difference between interface and abstract class

  61. i 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?

  62. plz send me the complete tutorials so that it will helps me a lot

  63. Thank you so much for giving the best Answer…

    because of i am so confused
    Thank you again.

  64. abstract class and java class both are same or different???

  65. HI Joseph,

    Let me know that why we are choosing “Interface” & “Abstract class” for a good application..

    Thanks in advance,

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

  67. my first ques is 1)6 points of difference between object and class.
    2)6 points of difference between dynamic binding and message passing.

  68. ques) explain briefly why cant we use a keyword as a variable name???

  69. tell me true or false…
    1. 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.

  70. This is quiet good….
    It may be useful for interview…

  71. This is really good….
    It is useful for interview

  72. Its so easy to learn even if the people doesn’t know java

  73. Hi Joe,

    Can you please tell me when to use Abstract class and when to use Interface in an application?

  74. give reallife example of interface…….

  75. hey i didnt get my answers,,,,,,,,,,,,

  76. thank u sir

    plz mail me similarities between an interface and classes

  77. In interfaces we cannot have any implementation for methods but that’s not the case with abstract classes we can have implementation for methods.

  78. thank you for giving informations
    but i want more details …..

  79. nice explanation for interface and abstract class

  80. It is very use full for me….. Thank you… by V.Vinoth from poondi

  81. Thank you very much … it was very useful to me

  82. thank u for giving this wondarful information

  83. Hi 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.
    Thanks and Regards,
    Praveen G

  84. plz give me the 6 points of difference between messege passing and message binding……..

  85. i still have a doubt, when we have to use interface and when we have to use abstract(class as well as method)

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

  87. its really helpfull for my class lacture

  88. what is the main reason to create abstract class?…..
    sir i know we cant create object of abstract class and we also provide method body in abstract class compare to interface…

  89. difference b/w instance variable and class variable.

  90. what are the changes to a variable ,method and a class when a final keyword is added to them.

  91. I 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 ?

  92. thank you for information about abstact class and interface

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

  94. some 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…..

  95. can u send me the real time example that when do we use interfaces and when do we use abstract class

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

  97. Abstract class start with letter “A” and Interface starts with letter “I”.

  98. What is the purpose of using Abstract class????

  99. Hi,please provide the Real-time examples for Interface and the Abstract class.So that every one can understand easily..

  100. Hi Joe ,
    when we have to use abstract class & interfaces can you explain

  101. If i create any reference variable to an interface and also i create the object of implementing the class.just mail me the difference

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

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

    Please help me.
    -Thanks in advance

  104. 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.
    -Thanks in advance

  105. what if abstract class implements two interfaces then it has to provide bodies for method declarations in interfaces or not?

  106. when we have to use abstract class & when we have to use interfaces can you explain

  107. Thank 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?

  108. Thank you for clearing doubts…..please send this book to my mail id…i have some more doubts

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

  110. hiiii gud source of info……keep goin!!

  111. catch
    cout<<"The quotient is "<<quotient<<endl;
    try(char *exceptionString)
    wat is the error in this code……..

  112. Thank you sir it is really helpfull to me keep going on………..

  113. Thanks a lot !!!!!!!!!!!!
    you are The Best.
    Thanks for writing and maintaining this nice blog. this is very nice blog.

    pranav thipse.

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

  115. Hi joe,
    I 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.)

  116. i stil hav a lot of doubts.can u jst giv some example and also show whn to use wht?

  117. it was really nice and in a very simple language… thanks joe

  118. can any1 give me A simple program for managing abstract and interface which includes all aspects as joe said?

  119. can any body explain me constructor in detail…i don’t no the use of it pls. explain me..

  120. Thanks joe really helpful,But I’m having confusion about the term “extra indirection” used in 8th difference can u please explain what it is ?

  121. I 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???

  122. can you please explain how the servlet communication done to other? explain different ways ?

  123. Thanks you for giving to this this answer.

  124. Some simple examples would be really great :)

  125. Please any one explain ,where we use Abstract calss and where we use interface .
    Plese give example

  126. is an interface implicitly an abstract class?


    • No. An interface is not an absrract class implicitly. Those two are interpreted in a different way.

  127. any book to get a good knowledge of java in simple and easy text?

  128. hi 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)

  129. hiii,,,,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)

  130. In the 7th difference pls give an example that how can we invoke abstract class if main exist…

  131. Nice work again…but i don’t understand 7th difference,can u explain me in detail.

  132. Is 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;

    * @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()
    return true;
    void remove()
    public static void main (String args[])
    MyInno my=new MyInno();

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


  134. nice explanation .Can u tell me how can we instantiate Abstract class

    • by extends that abstract class by concrete class means public class classname extends Abstract class.
      sub class that extends super abstract class
      we create object to sub class that is also called super class object becoz super class behaviours and methods all came to sub class so it is also super class object

  135. No, 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

  136. Joe, 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

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

  138. theoritically good .try to show it with examples….

  139. Thanks a lot !!!!!!!!!!!!
    is very useful for my exam preperation
    Thanks again

  140. Thank u very much…… this explanation is short pls put more anyway thanks guyz

  141. such a nice example for prepare an interview

  142. Hi all,
    I 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,

  143. when we use abstract class? and when we use interface? pls reply

  144. Can you please explain with an example for both abstract and interface? It is very useful and easily understand

  145. when do we use interface and abstract class ?? what is the necessity of using both of them differently if they are similar to each other ?

  146. where should we use interface and Abstract?

  147. Please let me know how the abstract class is faster than interface

  148. Interface Requires more time to find the actual method in the corresponding classes.
    this is why Abstract class implementation is faster than interface

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

  150. why we use interface or abstract class and what is the best approch interface or abstract class

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

  152. Is 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;

    * @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()
    return true;
    void remove()
    public static void main (String args[])
    MyInno my=new MyInno();

  153. Can we extends the interface ? if yes then show me by one example if no then tell me a proper reason ?

  154. thanks for giving valuble information…….. friends please send some more java material to me my e-mail is:govind.588@gmail.com

  155. if any interface is enxtend the same abstact method with in the abstract class then what will happen……. how? please send me one example////

  156. What is the significance of Interface?

    Its just a declaration of method names. But the implementation is still in the class.

    Any one can answer?

  157. joe .plz explain
    how transient keyword works with small example and what do u mean by serialization

  158. hi joe
    can i know exact usage of both interface and abstract class?

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

  160. hi 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 …


  161. Thanx for difference …
    it is help me lot in tomorrow exam of java ….

  162. Could you Please Explain Difference Between Interface and abstract class with real time example?

  163. malli,
    “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

  164. hi, 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…..

  165. Very useful and very clear. Thanks.

  166. 1 more diff=
    An interface cannot have a constructor whereas an abstract class can have a constructor which is called indirectly by the derived class.

  167. Proud to see a chennai guy coming up with lot of info..

    Generally only Americans do this…

    Thanks a lot…

    Ur website is very interesting and attractive….

    If u cannot share ur pone number pls call me at 9543111591.
    I wanted to ask u some doubts..

    Ramaseshan , Chennai

  168. sir can u plz explain the difference between an abstract class and an interface through a small program… i mean can u plz give me a code which can only be implemented by using an interface not by using an abstract class…???

  169. when to use abstract and when to use interface would you explain with an ex. sir

  170. Pingback: JDBC Introduction

  171. Hi sir,

    i like your blof content very much. but i would like if you would give some practival scenario laong with the points. likw e.g whne Interface is good and bad. same for teh ABSTRACT classes. which one to choose when. specially we are open to both.

    Thanks in advance..

    | Mayur Kumar

  172. Can you please explain about when to go for interface and abstract class?

  173. Hi Joi,
    I have my own doubt if you can clarify.

    When we compile a class or interface java create .class file.

    For example if we create Test.java and it contains
    public class Test{….}

    in other file if we create
    public interface Test{….}

    on compilation both file will be created as .class then how can we know that whether we need to extends or implements if we don’t have any IDE.


  174. These r text book differences write some real time orientation sir…………

  175. JOE dear,
    In Diiference # 3. You have added that the Abstract Members can be Private Flavour..is that possible to have Private Method in Abstract Class…???????

    If your Answer is Yes Please Post executable Code…

    • Hi,
      We can have private method as we can call the private method inside another non abstract method.:)

  176. Why we have only final variables declared in an interface?

  177. I want miniproject title in core java..please suggest me.

  178. @priyanka

    Answer to you question

    All variable in interfaces are final by default

    • Why all variables are final in interface?

  179. could you please explanin me the exception handling concepts

  180. Its said like interface can have private members and default is public. But, I don think its true. Can anyone please confirm this??? Can interface have private members??

  181. Sorry for the wrong information. It was a misunderstanding. Kindly ignore!!!

  182. what is return type of constructor in a java

  183. constructor can’t have any constructor….

  184. @Sanjeev

    Constructor is not a method, so it cannot have a return type, but can have arguments and access modifiers.

  185. in point 5 the statement is there interface can extends another interfaces but interfaces are used using implements keyword

  186. can unterface can be use through extends keyword because extebds is use for only classes

  187. you are telling differences
    but not telling about the correct features like where do we use abstract and where do we use interfaces in real time scenarios?

  188. Hi Joe

    One of my sincere request can u give a real time scenario where to use abstract class and where to use interface.

  189. very useful to me…
    Thanks a lot………….

  190. When to use Abstract and when to use Interface ?

  191. Hi joe

    A Java abstract class can have instance methods that implements a default behavior.

    I Can’t understand what that means please clarify using some example.

  192. This explanation is good but, can you explain when to use interface over abstract class and when to use abstract class over interface ..

  193. Hi Joe,
    – One more difference between Interface and Abstract class is that:

    Abstract class contain Constructor Where as Interface does not contain Constructor.

    If any mistake is there then PLZ let me knw.

  194. what is the difference between Interfaces and abstract? please give the real time example ?

  195. when to use interface and when to use abstract class? please send the clear example sir?

  196. why is abstract class is needed?everybody says for extending a common functionality throghout the application we define an abstract class with one concrete method which holds the common logic and extend this abstact class.we can define a concrete class and subclass it..right?.what is the real need to define an abstract class here?

  197. hello ,this is a good information to know about interface and abstract class.pls send me a copy of these java papers.

  198. when we should go for interface and when we should go for abstract class?

  199. OVERRIDDING-when you extend a class and write a method in the derived class which is exactly similar to the one present in the base class, it is termed as overriding.
    public class BaseClass{

    public void methodToOverride()


    //Some code here



    public class DerivedClass extends BaseClass{

    public void methodToOverride()


    //Some new code here



    OVERLOADING-More than one method, in the same class shares a same name but different arguement is called overloading..
    public class OverLoadingExample{

    public void add(int i, int j)


    int k = i + j;


    public void add(String s, String t)


    int k = Integer.parseInt(s) + Integer.parseInt(t);



    You wanna learn html visit http://htmlatul.host56.com

  200. it’s really valuable……….
    thanks to you for explanation………

  201. Respected Sir,

    I want talk to you.I have more doubts please clear to me. your explanation is okay but u dont mention realtime and practical information

  202. Sir,i have one doubt with abstract class..
    Why we need abstract classes in java??..

  203. how do we pass values for concrete methods from main function in abstract class

  204. Very nice and simple explanation. if can you have information what is precise difference
    why interface is slow,why to use interface or abstract. What is need of two interface and abstract concepts in Java.

  205. 7.Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated,????????????

    HttpServlet is an abstract class;

    new HttpServlet(){};

    Servlet is an interface;

    new Socket(){
    implements all methods;

  206. this is nice i want some more explanation with example for about interface and abstract class…….

  207. this is nice sir but which one is pure abstract either interface nor abstract class

  208. in which condition abstract class failure but interfaces are used.

  209. i want one answer related on interface?
    when one class can be implements an interface and as same class extends one another abstract class of this interface.?
    that is possible ?

  210. //this is possible?plz give me ans.
    interface r1{
    void display();
    void add(int i,int j);
    int ram(int k);
    void ganesh(char c);

    abstract class ram implements r1{

    ram() {
    System.out.println(“constructor is called”);

    public abstract void ganesh(char c);

    public int ram(int k){
    return k;

    public void display()
    System.out.println(“i am here”);

    public void add(int i,int j)
    System.out.println(“i and j value is”+i +” “+j);

    void display(int k)
    System.out.println(“the value is”+k);

    class a implements r1 extends ram
    public void ganesh() {
    System.out.println(“this is”);

    class i {
    public static void main(String args[])
    a var=new a();
    a.display( );

  211. differences between collection and collections in detail please explain this am not able to understand

  212. Hi

    I want to know when can i prefer Abstract Class or Interface.

    ie When can i choose Abstract Class or Interface.

    Please explain somebody, because i have little bit confusion on that

    Kindly please explain some body effectivly…

  213. //Interface
    public interface interfaces {
    void multiply();

    public abstract class AbstractClass {
    abstract void add();
    void display(){
    System.out.println(“hello world”);
    public class superClass extends AbstractClass implements interfaces{

    void add() {
    int a=10;int b=10;int c;
    void sub(){
    int a=10;int b=10;int c;
    //method implementation
    public void multiply() {
    int a=10;int b=10;int c;




    public class subClass extends superClass {
    public static void main(String[] args) {
    subClass s=new subClass();
    // code reusability
    interfaces inter=new superClass();

  214. differences between collection and collections in detail please explain this am not able to understand

    Collection is an Interface it will extends Iterable Interface.
    Collections is a Class it will extends a
    Object class.

  215. I want to know..In MultiThreading if I am using HashMap means is there any chance to occur DeadLocks?

  216. what is the use of abstract class? give some examples?

  217. which is the best way to increase the application perfomance?(Multithreading Application)

    1.Extending Thread.
    2.Implementing Runnable Interface.

  218. why it is said that java provides more security than any other language?

  219. why it is said that java provides more security than any other language?

  220. Hi Joe,

    Thanks for the detailed articles…your site is very good for beginners as well as for experienced java programmers…

    About the interfaces and abstract class one thing always come to my mind that why do we need an abstract class? As if I write an abstract class with all abstract methods then there is no difference between interface and abstract class so why to have it?
    If given a chance to write an abstract class or an interface which one to choose?

  221. Thank you..Outstanding discription.

  222. Thanks.Outstanding discription.

  223. using System;

    namespace AbstractsANDInterfaces

    /// Summary description for Employee.


    public abstract class Employee
    //we can have fields and properties

    //in the Abstract class

    protected String id;
    protected String lname;
    protected String fname;


    public abstract String ID

    public abstract String FirstName

    public abstract String LastName
    //completed methods

    public String Update()
    return “Employee ” + id + ” ” +
    lname + ” ” + fname +
    ” updated”;
    //completed methods

    public String Add()
    return “Employee ” + id + ” ” +
    lname + ” ” + fname +
    ” added”;
    //completed methods

    public String Delete()
    return “Employee ” + id + ” ” +
    lname + ” ” + fname +
    ” deleted”;
    //completed methods

    public String Search()
    return “Employee ” + id + ” ” +
    lname + ” ” + fname +
    ” found”;

    //abstract method that is different

    //from Fulltime and Contractor

    //therefore i keep it uncompleted and

    //let each implementation

    //complete it the way they calculate the wage.

    public abstract String CalculateWage();


  224. Feature


    Abstract class

    Multiple inheritance

    A class may inherit several interfaces.

    A class may inherit only one abstract class.

    Default implementation

    An interface cannot provide any code, just the signature.

    An abstract class can provide complete, default code and/or just the details that have to be overridden.
    Access Modfiers An interface cannot have access modifiers for the subs, functions, properties etc everything is assumed as public An abstract class can contain access modifiers for the subs, functions, properties

    Core VS Peripheral

    Interfaces are used to define the peripheral abilities of a class. In other words both Human and Vehicle can inherit from a IMovable interface.

    An abstract class defines the core identity of a class and there it is used for objects of the same type.


    If various implementations only share method signatures then it is better to use Interfaces.

    If various implementations are of the same kind and use common behaviour or status then abstract class is better to use.


    Requires more time to find the actual method in the corresponding classes.


    Adding functionality (Versioning)

    If we add a new method to an Interface then we have to track down all the implementations of the interface and define implementation for the new method.

    If we add a new method to an abstract class then we have the option of providing default implementation and therefore all the existing code might work properly.
    Fields and Constants No fields can be defined in interfaces An abstract class can have fields and constrants defined

  225. When to use Abstract and when to use Interface ?

  226. When to use Abstract and when to use Interface ?

  227. Hi,

    Thankx for posting this article, but ,
    instead of posting what is there in books, you explain the main difference with an example. That may use for beginners who are reading this article.

  228. Dear friend,
    could you please send your core java preparation kit.

  229. sound great…..!

    Dear joe, you can also add particular program based on any topics for the
    demonstration ,so we can understand this better way.
    and u r site structure is inovatic.

  230. Is it possible that an abstract class have no any abstract method?

  231. thank you….
    its easy to understand…..

  232. thnx ….
    its easy to understand…..

  233. hai im newly learning java i have question. i.e is in below

    In Java, under what circumstances would you use abstract classes instead of interfaces? When you declare a method as abstract, can other nonabstract methods access it? In general, could you explain what abstract classes are and when you might use them?

  234. Those are all excellent questions: the kind that everyone should ask as they begin to dig deeper into the Java language and object-oriented programming in general

    Yes, other nonabstract methods can access a method that you declare as abstract.

    But first, let’s look at when to use normal class definitions and when to use interfaces. Then I’ll tackle abstract classes.
    Class vs. interface

    Some say you should define all classes in terms of interfaces, but I think recommendation seems a bit extreme. I use interfaces when I see that something in my design will change frequently.

    For example, the Strategy pattern lets you swap new algorithms and processes into your program without altering the objects that use them. A media player might know how to play CDs, MP3s, and wav files. Of course, you don’t want to hardcode those playback algorithms into the player; that will make it difficult to add a new format like AVI. Furthermore, your code will be littered with useless case statements. And to add insult to injury, you will need to update those case statements each time you add a new algorithm. All in all, this is not a very object-oriented way to program.

    With the Strategy pattern, you can simply encapsulate the algorithm behind an object. If you do that, you can provide new media plug-ins at any time. Let’s call the plug-in class MediaStrategy. That object would have one method: playStream(Stream s). So to add a new algorithm, we simply extend our algorithm class. Now, when the program encounters the new media type, it simply delegates the playing of the stream to our media strategy. Of course, you’ll need some plumbing to properly instantiate the algorithm strategies you will need.

    This is an excellent place to use an interface. We’ve used the Strategy pattern, which clearly indicates a place in the design that will change. Thus, you should define the strategy as an interface. You should generally favor interfaces over inheritance when you want an object to have a certain type; in this case, MediaStrategy. Relying on inheritance for type identity is dangerous; it locks you into a particular inheritance hierarchy. Java doesn’t allow multiple inheritance, so you can’t extend something that gives you a useful implementation or more type identity.
    Interface vs. abstract class

    Choosing interfaces and abstract classes is not an either/or proposition. If you need to change your design, make it an interface. However, you may have abstract classes that provide some default behavior. Abstract classes are excellent candidates inside of application frameworks.

    Abstract classes let you define some behaviors; they force your subclasses to provide others. For example, if you have an application framework, an abstract class may provide default services such as event and message handling. Those services allow your application to plug in to your application framework. However, there is some application-specific functionality that only your application can perform. Such functionality might include startup and shutdown tasks, which are often application-dependent. So instead of trying to define that behavior itself, the abstract base class can declare abstract shutdown and startup methods. The base class knows that it needs those methods, but an abstract class lets your class admit that it doesn’t know how to perform those actions; it only knows that it must initiate the actions. When it is time to start up, the abstract class can call the startup method. When the base class calls this method, Java calls the method defined by the child class.

  235. page is developed very nicely… i liked it…

  236. Hi All,

    Interface is also method It was implemented in class.But abstract class contain abstaract methods(I mean concrete methos)

    multiple interface is implemented with interface.But with abstract class its not possible.

    Interface contains all public static variable and methods.But in abstract class static variables,static blocks,concrete methoods

    defination of abstract class:
    class A{
    int sum(){
    abstract class B extends A{


    B is called abstract class because it should not override all the methods and parameters in super class A so it is called
    abstract class.

  237. sorry multiple inheritance implementer with interface but with abstract class its not possible

  238. The explanation which is very transparant.

  239. Pls Send me A Complete boook For java…

  240. Joe u wrote that an interface can extend multiple interfaces but java does not support multiple inheritance so how this is possible ? please explain .

  241. Hi, this is Harold Kumar Oreocookie Gupta, of the Gupta family in India.

    Can you write me example of the aforementioned article? Ideally with examples of the main concepts and differences given by your beloved article? I’ll be waiting for your examples and I’ll check back tomorrow afternoon precisely at 15:00.

    • Harold,

      I don’t get you! You want an example for an interface and an abstract class, is it? Those are straight forward!

  242. why does java have both abstract class as well as interface? what is the need or importance of having both?

    • Interface has incomplete implementation so that a user can do it himself as needed,it also forces the implementing class to write for the methodsw in interface,so that becomes a standard.While in case of abstract class the user can override the methods of superclass or can use the implementation written in that superclass …

  243. Hi Joe,

    Thanks a lot for your article posted. Could you please provide me an example program for interface and abstract classes better can understand?
    Thanks in advance for your reply.


    • java introduced interfaces for solving multiple inheritence (which it donot support) A class(particular class) can be a subclass of only one super class, but an interface can extend as many other interfaces as you want. Just list them after extends, separated by commas.

      public interface interfaceName extends superinterfaceName,superinterfaceName1,superinterfaceName2
      interface body…

      and coming to abstract class is a class which may or may not contain abstract methods but if does the child class which inherits it must do implementation for abstract methods
      abstract class A()
      public void add();
      public void bark();
      class B implements A
      public int add()
      //some code for addition;
      public int bark()
      //some code for bark;


      note:class cannot implement an interface but it can extends the interface

      • ‘java introduced interfaces for solving multiple inheritence (which it donot support)’

        Believe Java guys had a reason for not supporting multiple inheritance by not allowing extending from multiple classes. What could be the reason for it. And if multiple inheritance was not desired, y did they allow implementation of multiple interfaces?

  244. what is real time use of interface and abstract class..can u explain Joe?..I am waiting for your valuable reply

    thanks in advance

  245. ur content is good but i think u must change background color caz its difficult see content wid hat brown back ground
    u can feel that tooo by watching content in blog and our comments bakground

  246. We can add below,
    1,We can restrict the Method access outside of the class.If class A has 5 methods and Client A1 wants only 3 methods and Client B1 wants 2 methods then we can implement corresponding interfaces 1 has 3 methods and another has 2 methods and same will be used in client.
    2.We can generate Dynamic proxies using interfaces whereas its not possible in abstract class.

  247. Which one is better in Inheritance and Interface?
    Please give me example also.

  248. 1)we can compile and execute abstract class But Interface class only Compile not Execute …

    2)abstract class can extends only one class But Interface can extends Multiple interfaces
    Ex. interface C extends A,B
    But in Abstract class B extends A only..

  249. When do use interface and abstract class in the following case when both looks the same?

    public interface TestInterface {

    void method1();
    void method2();

    public abstract TestAbstract {
    void method1();
    void method2();

    Please advise..

  250. pls send some java material because i applied for ocjp

  251. dude an abstract class can’t impalement Interface…………..i think u r wrong!!!!

  252. vary nice difference is easy understandable

  253. can u give the real time example for the abstract class and interfaces

  254. Thanks, I have one doubt
    In one of the interview they asked like this
    any other use is there for Interfaces? other than Multiple Inheritance?

  255. how we can implement security on web-site, which ve developed in java.

  256. why java using class ,abstract class and interface

  257. why we are using string args[] in main method header

  258. Please tell me different scenario for both interface and abstract class when can we use ?

  259. Sir,

    in what situation we have to use abstract class or interface .interfaces has only method declaration what is the use of it?

  260. An abstract class allows you to provide a default implementation for some of the methods but an interface does not allow you to provide any implementations.

    You can implement multiple interfaces but you can only inherit from one abstract class.

  261. when do we create interface instead of creating abstract class??

  262. Hey that’s a nice tutorial…..But i just want to know what is the real use of the interface except Multiple Inheritance……………Please I’m confused

  263. According to me,,:

    An interface consists of abstract methods only and if we implement any interface into our concrete class we have to give the body of all the abstract functions of the interface,, but if i make a toString method in my concrete class which implementing an interface, the toString method is working efficiently, whereas there is no abstract method in the interface…..

    And if the toString method is coming from the object class then it must be coming with some other methods also, then why we haven’t given the body of all other functions in our concrete child class…

    Please correct me and guide me for this, its a humble request joe sir…

    thanking you in advance…

  264. This difference is syntactically which is not good
    You have to give difference by real time use .
    Suppose i make all method as abstract in abstract class and this method are also in interface then abstract and interface become same so why java found interface? Any body have Answer of my Question then please send me mail

    • kamlesh , i think interfaces helps in achieving multiple inheritance, thus we need them too.

      hope this satisfy your question a lil bit.

  265. Hi Joe,

    I am big fan of your blog. several times, I got a big help from this for searching answers tuff FAQs of interviews…………

    I want to add one thing that this question is SUPER-HOT and EVERGREEN in any java interview……..but as per your another answers of another question on your blog ………….this answer is just childish……..So please post your response in a professional manner to understand the need and use of both the concepts into the root level.

    I want to understand properly about Abstract Classes and Interfaces that………..at which situation we generally use Abstract classes??????? and in which specific situation, we use Interfaces………?????? Would U please give explanatory response for this with real-time examples…………

  266. Hi,
    Can u write code for this point
    7.Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.

    I tried but no result yet..

  267. back ground is too worst please change the back ground as early as possible we could not find the words and letters.
    with regards,

  268. hai sir, i hava one question.

    There is a list of countries.
    and each country has some number of products.

    To store these which collection class should I take.. and how would I store them.

    please reply with answer.

    thankyou sir.

    • Go for HashMap, Country Name is your key and list of product your ArrayList.

      For Example,

      if Country India having


      map.put(“India”, list);

    • Its better to the apache commons collection class MultiValueMap there this can be done very relaible

  269. Abstract class: some
    implementations, some
    methods abstract
    (method definition

  270. Change the font color or change the background. I feel it not readable.

  271. please relist your topics sequentially to make this tutorial even more valuable. And make the missing topic available. great tutorial by the way.

  272. i like 7 difference bcoz it contain logic,u show good difference.


  273. in which situation we have to use interface and abstract class

  274. which situation we have to use interface and abstract class

  275. Hi Joe, You have given a bookish points. Why don’t you tell us what is the use of interfaces or abstract class? Why do we need both of them, either of one is sufficient. Isn’t it? What are their individual importance?

  276. “public void abstract class Employee” and “public void Employee(String name, String address, int number)” These two lines are wrong.. a class as well as a constructor cannot have any return type.

  277. Does an interface provide almost all benefits of multiple inheritance which is not supported in java.?

  278. why dont abstract methods have any implementations in an abstract class, but in subclass of the abstract class.?

  279. Interface couldn’t be implemented by any other Interface…..

  280. can u give me the difference between abstract class and interfaces

  281. It is an error to specify the static modifier for the abstract method.

  282. suppose there is only a one abstract method we have in a abstract class and in a interface…….which of them will be more benificial to implement or extend,a abstract class or a interface??///and why??? please tell

  283. In what scenario we use abstract class and interface ??

  284. in what scenario we use abstract class and interface ?

  285. Pingback: Decorator Design Pattern

  286. One more difference.
    Interface never participate in object creation while abstract class object is created with a child class object. Though developer can not create instance of abstract class by using new operator.

    Moreover, Interface are not used for multiple inheritance (What will you inherit from interface. It has nothing to be inherited).

    Interface are used in specifications like JDBC.

    Interface are used in remote accessebility (RMI). You can have 2 interfaces for one service. If you are providing one interface to client, he will not be able to call the methods defined in second interface.

  287. These differences are mostly syntactical and very specific to java. i found the most astounding differences:
    Interface is the peripheral identity of a class
    Abstract class is the central identity of a concrete class. You actually should not differentiate these two, however these two manifest the most powerful aspects of OOP

  288. Can any one explain:-

    1.Why connection,resultset and statement are interfaces?

    2.When above are interfaces then how can we call their functions as they don’t have method implementation(By Interface definition).

    • that should be implimente by thired party provider

  289. by using Abstract class u cont extends multible inhertence,but by using interface we can achive multible inheritence said on ,

    by using Abstract class u cont extends multible inhertence,but by using interface we can achive multible inheritence

  290. abstract classes can contain constructor

  291. public abstract class AbstratctClassTest {
    public AbstratctClassTest(String str){
    System.out.println(“AbstratctClassTest is calling “+str);

    public static void main(String str[]){
    Abst obj=new Abst(“hi”);

    class Abst extends AbstratctClassTest
    public Abst(String str){
    System.out.println(“in abst constructore”);
    void sayHello(){

  292. As I understand one more difference:

    Interface describes ability of the class.
    Abstract class describes identity of the class.
    Therefore you can have many abilities but just one identity.

    Please add this to your post if found appropriate.

  293. can anyone tell me in which situation one can use abstract class and one can use interface????

    • if we dont know anything(for example:zero percentage) about implementation go for INTERFACE
      if we know something(for example:roughly 30 to 40 % percentage) about implementation go for abstract class as an abstract class can contain both defined(implemented) and undefined(abstract or unimplemented )methods
      if we know every thing(for example 100% not exactly but almost) about implementation then go for conrrete class that is class

      • Hi Raju,

        Then why we will use interface according to your answer. if we know more less than then also its better to go directly abstract classes. Then why this interface came to market. Can you please explain me this?

        Thanks & Regards
        Sailendra Narayan Jena

  294. please tell me what is the use of interface,when we can instead of interface can we use abstract class contain only abstract method(pure abstract class)

  295. Scientific calculation using event driven programmi ng…
    i need this program,,plz send me soon..

  296. hi,
    The interfaces are not default final because it can be extended
    final class can not be sub-classed.

  297. why do we actually need interface???when abstract class only can do what ever the things done by interface?apart from multiple inheritance?

  298. Really your blog superb to learn about java

  299. Really your blog is superb for learning java..

  300. Hi,

    I want to know the exact difference means in which scenarios we will use abstract class and in which scenarios we will use interface.

    My another question on this topic is:
    1. We know that we can’t create object for both interface and abstract class but can you tell me as you have mentioned there in case of main method how we will create the object for the abstract class with examples?

    2. In case of project scenarios if we are creating interface then what is the need for this interface in future cases, which class implements that interface and if we will add some new method inside this interface in future then also it will reflect to all those classes where its got implements. So can you please explain me?

    Thanks & Regards
    Sailendra Narayan Jena

  301. what is extra indirection….you have mentioned in the 8 point….plzz explain

  302. hi joe!…your every article is very admirable…Can u please explain 8th point

  303. //* Program of implement the interface Keyword *//

    interface A
    void sum();
    class B implements A
    public void sum()
    int a=12,b=3,c;
    System.out.println(“Sum of the number =”+c);
    class Result
    public static void main(String as[])
    B s1=new B();

  304. what is the real time difference between abstract and interface?
    Like When are you going to use abstract and interface in real time project development.

  305. I m totally confused. Can u explain me the difference between abstract class and interface

  306. Very nice sir … thanks a lot for sharing your knowledge with us…..

  307. Hi, the 5th point says that an interface can extend another interface only, but actually an interface can extend multiple interfaces. Correct me if I am wrong.

  308. hi joe,
    5th point is wrong, i.e an interface can extend any number of interfaces

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>